PDA

View Full Version : Anyone help me with TCL please?


EwarWoo
12-07-2005, 10:11 PM
I'm trying to bodge together a little bot script, however having never used TCL before I'm struggling and I'm sure my syntax is completely whacked. I'm trying to bodge a script to restart ioFTPD if its down:

bind pub o|o !start proc_iostart

proc proc_iostart {nick uhost hand chan args} {
global binary announce
putquick "PRIVMSG $chan :-\[START\] + Attempting to start ioFTPD"
cd c:/FTP-SERVER/ioFTPD/system
exec pslist ioFTPD > nul
If
(ERRORLEVEL 1) {
exec ioFTPD.exe
putquick "PRIVMSG $chan :-\[START\] + ioFTPD started"
}
Else
{
putquick "PRIVMSG $chan :-\[START\] + ioFTPD already running"
}
cd c:/FTP-SERVER/sitebot/
}

I currently get an error stating if is an invalid command.
I was wanting to just run a bat file from here and it was working however it didn't exit correctly so froze the bot so I'm trying to insert it directly into the script.

@echo off
CD d:\path\to\ioFTPD\system
pslist ioFTPD > nul
IF ERRORLEVEL 1 GOTO restart
GOTO END

:RESTART
CD d:\path\to\ioFTPD\system
start ioFTPD.exe

:END

R2_2k
12-13-2005, 10:04 PM
bind pub o|o !start proc_iostart

proc proc_iostart {nick uhost hand chan args} {
global binary announce
putquick "PRIVMSG $chan :-\[START\] + Attempting to start ioFTPD"
cd c:/FTP-SERVER/ioFTPD/system
exec pslist ioFTPD > nul
If
# (ERRORLEVEL 1) {
#### TCL IFS USE :: IF { } { } format no ()'s
#if {$errorlevel??? == 1} or if {$errorlevel}


exec ioFTPD.exe
putquick "PRIVMSG $chan :-\[START\] + ioFTPD started"
}
Else
{
putquick "PRIVMSG $chan :-\[START\] + ioFTPD already running"
}
cd c:/FTP-SERVER/sitebot/
}

what does ps list return?
probably should be more like set ps [exec pslist ioFTPD> nul(null?)]

EwarWoo
12-14-2005, 05:44 AM
I now have:
bind pub o|o !start proc_iostart

proc proc_iostart {nick uhost hand chan args} {
global binary announce
putquick "PRIVMSG $chan :-\[START\] + Attempting to start ioFTPD"
cd c:/FTP-SERVER/ioFTPD/system
set ps [exec pslist ioFTPD > nul]
IF {$errorlevel == 1} {
exec ioFTPD.exe
putquick "PRIVMSG $chan :-\[START\] + ioFTPD started"
}
Else {
putquick "PRIVMSG $chan :-\[START\] + ioFTPD already running"
}
cd c:/FTP-SEVER/sitebot/
}

putlog "ioStart \[Loaded\]"

and still getting if is an invalid command :/

Think I'll leave the coding to you guys who know what you're doing. Hehe

Cheers for the help anyways bud, appreciated.

R2_2k
12-14-2005, 08:45 AM
I now have:
bind pub o|o !start proc_iostart

proc proc_iostart {nick uhost hand chan args} {
global binary announce
putquick "PRIVMSG $chan :-\[START\] + Attempting to start ioFTPD"
cd c:/FTP-SERVER/ioFTPD/system
set ps [exec pslist ioFTPD > nul]
IF {$errorlevel == 1} {
exec ioFTPD.exe
putquick "PRIVMSG $chan :-\[START\] + ioFTPD started"
}
Else {
putquick "PRIVMSG $chan :-\[START\] + ioFTPD already running"
}
cd c:/FTP-SEVER/sitebot/
}

putlog "ioStart \[Loaded\]"

and still getting if is an invalid command :/

Think I'll leave the coding to you guys who know what you're doing. Hehe

Cheers for the help anyways bud, appreciated.


Okay Well try if else (tcl == case sensitive) so make all (unless otherwise known) cmds lowercase

R2_2k
12-14-2005, 11:13 AM
bind pub o|o !start proc_iostart

set ios(dir) "c:/FTP-SERVER/ioFTPD/system"

proc proc_iostart {nick uhost hand chan args} {
global ios
### i do not see bin or ano used here so i removed them from global
putquick "PRIVMSG $chan :-\[START\] + Attempting to start ioFTPD"

# cd c:/FTP-SERVER/ioFTPD/system
### Replaced with $ios(dir)\executable
set ps [exec $ios(dir)\pslist ioFTPD > nul]
if {$errorInfo == 1} {
# no idea what errorlevel is; assuming its errorInfo
## if you paste back what pslist ioFTPD returns could make that alot better #statement -i need too install io :P
exec $ios(dir)\ioFTPD.exe
putquick "PRIVMSG $chan :-\[START\] + ioFTPD started"
}
else {
putquick "PRIVMSG $chan :-\[START\] + ioFTPD already running"
}

# cd c:/FTP-SEVER/sitebot/
}

putlog "ioStart \[Loaded\]"



Yup so i tried too msg you on ole efnet but seems your afk for last +1days you still prowl around those parts?

EwarWoo
12-14-2005, 09:45 PM
I think I still have a script uidling on there but I rarely check it, dont get much chance to sit at computer when home anymore, too busy.
I'll have a look when I get in tonight, see if you're around, and let ya know if this works.

Cheers :)

EwarWoo
12-17-2005, 07:17 PM
I gave up on it, I have this running every 10 mins via wincron instead:

@echo off
CD c:\ftp-server\ioFTPD\system
pslist ioFTPD > nul
IF ERRORLEVEL 1 GOTO restart
GOTO RUNNING

:RESTART
echo ioFTPD not running, restarting >> c:\FTP-SERVER\ioFTPD\logs\ioRunning.log
echo |time |find "current" >> c:\FTP-SERVER\ioFTPD\logs\ioRunning.log
start ioFTPD.exe
GOTO END

:RUNNING
echo ioFTPD already running >> c:\FTP-SERVER\ioFTPD\logs\ioRunning.log
echo |time |find "current" >> c:\FTP-SERVER\ioFTPD\logs\ioRunning.log

:END

Ugly but works :)