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.

exec help

Old posts that have not been replied to for several years.
Locked
d
digitaldj
Voice
Posts: 23
Joined: Tue Jan 07, 2003 9:07 am

exec help

Post by digitaldj »

hi. I'm working on a little script, and it's suppose to run a .sh file. But if the return is more than 1 line, it gives a TCl error. i was told to use 'foreach', so can anyone give me an example or something? thanks.
User avatar
caesar
Mint Rubber
Posts: 3777
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

See http://tcl.activestate.com/man/tcl8.2.3 ... oreach.htm for examples. Also be careful with the exec thing.. Read more about how to use it here: http://tcl.activestate.com/man/tcl8.2.3/TclCmd/exec.htm

Also you may want to use: bgexec.tcl wich is a "TCL for other scripters to use as a replacement for the 'exec' tcl command, as it uses non-blocking i/o." You can find it here: http://www.tclscript.com/ or download it directly from: http://strike.vectorstar.net/cgi-bin/dl ... xec.tcl.gz

Hope this helps. :)
Once the game is over, the king and the pawn go back in the same box.
d
digitaldj
Voice
Posts: 23
Joined: Tue Jan 07, 2003 9:07 am

Post by digitaldj »

hehe.. yea, should help :P thanks.
User avatar
caesar
Mint Rubber
Posts: 3777
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Your welcome. Post an reply if you stuck or something like this. :wink:
Once the game is over, the king and the pawn go back in the same box.
d
digitaldj
Voice
Posts: 23
Joined: Tue Jan 07, 2003 9:07 am

Post by digitaldj »

hmm.. well, there is one thing. i downloaded some other script with exec and .sh, and it runs perfect on a linux server with the newest eggdrop. but when i tried it on a freebsd with the newest 'drop it came with a tcl error. any diffrense between the os's when it comes to eggdrop? hm. might be the TCL, maybe i've got an old version or something
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

A copy of the error itself will usualy help.

The messages can be rather informative, and we can 9/10 times tell you your problem without tseeing the code (though tell you exactly what to change is another problem).
d
digitaldj
Voice
Posts: 23
Joined: Tue Jan 07, 2003 9:07 am

Post by digitaldj »

well, the script i downloaded that worked on a linux server, is a addon for the glftpd. the error is:

[13:56] Tcl error [pub:trialscript]: user is missing 2000 MB to pass with 3 days remaining, which means another 666 MB per day (2000 MB/week).

it's the same type of error on my script.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

The Tcl exec command will cause a TCL_ERROR, if it receives any output via STDERR.

This is what causes this issue. You script must output to STDERR.

Either change your script to output on STDOUT, rather than ERR, or use the Tcl "catch" command.
d
digitaldj
Voice
Posts: 23
Joined: Tue Jan 07, 2003 9:07 am

Post by digitaldj »

i cant paste my own code, since im not home and the server is local, but the script im talking about here now only does this:

set binary {/glftpd/bin/tur-trial.sh}
set who [lindex $text 0]
set output [exec $binary $who]
putserv "PRIVMSG $chan :$output"

so how do i change where to output?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

It is not the Tcl script that is faulting.

The .sh script is the one doing output to STDERR.

When you do the exec command, so somthing like

Code: Select all

if {[catch {set output [exec $binary $who]} err]} {
  set output $err
}
I realy don't know what the .sh script is outputing. I only know that at one stage, it output to STDERR.

As such, if the .sh script places somthing to the STDERR channel, the Tcl will use the error message instead of the message sent to STDIN.

If you want to capture both the STDIN and STDERR messages, then replace the "set output $err" line with

Code: Select all

append output "${err}\n"
d
digitaldj
Voice
Posts: 23
Joined: Tue Jan 07, 2003 9:07 am

Post by digitaldj »

Code: Select all

if {[catch {set output [exec $binary $who]} err]} { 
  set output $err 
} 
worked :D thanks.
Locked