This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Listing directory

Old posts that have not been replied to for several years.
Locked
r
rev_coil

Listing directory

Post by rev_coil »

Im hoping someone may be able to give me a hand with a little script that will list all files in a dircetory. I have one so far that works with eggdrop to add and remove a dir, but id like my egg to also list whats there (for ftp requests, etc) here's what i have so far for adding/deleting:

the .sh file:

REQDIR="/glftpd/site/Requests"
SITENAME="IcD"

if [ "$1" = "" ]; then
echo "Use it correctly"
exit 0
else

if [ "$1" = "add" ]; then

if [ "$2" = "" ]; then
echo "Specify a request... Usage: !req <release>"
exit 0
else
ALREADYTHERE="$( ls $REQDIR | grep $2 )"
if [ "$ALREADYTHERE" = "" ]; then
mkdir $REQDIR/$2-$3
echo "-$SITENAME- [REQ] + New Request: $2 by $3"
else
echo "Request already exsists, you sure you got it right?"
exit 0
fi
fi

else
if [ "$1" = "del" ]; then

if [ "$2" = "" ]; then
echo "Specify a request to delete... Usage: !delreq <release>"
exit 0
else
ALREADYTHERE="$( ls $REQDIR | grep $2 )"
if [ "$ALREADYTHERE" != "" ]; then
rm -fr $REQDIR/$ALREADYTHERE
echo "-$SITENAME- [REQ] - Deleted Request: $ALREADYTHERE"
else
echo "No request named like that, try to rephrase"
exit 0
fi
fi
fi
fi
fi
exit 0

and the .tcl file :

bind pub - !req pub:req
bind pub - !delreq pub:delreq

proc pub:req {nick uhost handle chan arg} {
set binary {/glftpd/bin/request.sh}
set what [lindex $arg 0]
set output [exec $binary add $what $nick]
puthelp "PRIVMSG $chan :$output"
}

proc pub:delreq {nick uhost handle chan arg} {
set binary {/glftpd/bin/request.sh}
set what [lindex $arg 0]
set output [exec $binary del $what]
puthelp "PRIVMSG $chan :$output"
}

putlog "request.tcl loaded"

if anyone may be able to help me with the dir listing part, id be forever grateful :))
M
MC_8
Voice
Posts: 36
Joined: Sat Apr 26, 2003 5:04 pm
Location: Dallas, Texas
Contact:

Post by MC_8 »

You can use the 'glob' command to have it list.
See: http://tcl.activestate.com/man/tcl8.3/TclCmd/glob.htm
Carl M. Gregory - MC_8
http://mc.purehype.net/whois/
M
MC_8
Voice
Posts: 36
Joined: Sat Apr 26, 2003 5:04 pm
Location: Dallas, Texas
Contact:

Post by MC_8 »

By the way

Code: Select all

set what [lindex $arg 0]
Should be

Code: Select all

set what [lindex [split $arg] 0]
Carl M. Gregory - MC_8
http://mc.purehype.net/whois/
Locked