looking for a solution to kind of call a shell script (.sh) which takes about 3 minutes to be finished into background without getting my eggdrop stuck and not responding at all.
fact is: its not possible to do it with exec since exec waits for a reply
possible solution: using something like set x [open "| myscript.sh"]?
do I also need a set x2 [read $x] or what else is needed to make it work, do I miss something in general anyway?
thx for all your help
Last edited by raider2k on Mon Dec 07, 2009 4:45 pm, edited 1 time in total.
Whether to use exec or open pretty much comes down to whether you need to maintain contact with the shell script (send text to it, read it's output, know if it's still running or not), or simply a "fire and forget" script...
If you don't care for what the script is doing or when it's completed, exec should do the trick. See the manpage for a list of possible pipe controls (&, |, etc).
If, however, you need to keep track of the script while it's running, you'll need to use open. As for reading the generated output, you'd probably use fileevents for this. I'd also recommend setting the file channel into non-blocking mode. There's a few good examples how to get all this working on the forum, but feel free to ask if you need further assistance with it.
Not quite, that would launch the script and redirect the stdout of the script to /dev/null. It would, however, still block while the script is running. The key part is this (quoted from the manpage):
If the last arg is ''&'' then the pipeline will be executed in background. In this case the exec command will return a list whose elements are the process identifiers for all of the subprocesses in the pipeline. The standard output from the last command in the pipeline will go to the application's standard output if it hasn't been redirected, and error output from all of the commands in the pipeline will go to the application's standard error file unless redirected.
So, what you need to do is suffix the commandline with a &
oh, oh?
exec $myshellscript &
is going to do the trick and ill never have a non-responding bot again when calling something that takes a hell of a time via exec?
Yup,
Since your eggie runs in the background, you'll probably want to redirect stdout and stderr to /dev/null to avoid garbage being spewed out to the terminal where you started your eggie, but & is enough to make the exec-call "non-blocking".