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.

[SOLVED] exec command stopped working after upgrade

Help for those learning Tcl or writing their own scripts.
Post Reply
d
dj-zath
Op
Posts: 134
Joined: Sat Nov 15, 2008 6:49 am
Contact:

[SOLVED] exec command stopped working after upgrade

Post by dj-zath »

hi everyone!

I got one for ya.. probably a newbie question, however, at this point I'm too tired and fustrated to deal with it..

Recently, my server CRASHED.. (why this happened is a point for a different discussion) so I had to have it shipped from the Co-Lo and then rebuild it.. from scratch!

except, this time around I wanted to upgrade all the goodies.. including eggdrop..

PROBLEM!

although the eggie installed, I quickly found that the "exec" command is no-longer being recongnized.. I even tried re-installing TCL and reverting back to an older version of TCL and then, the previous un-recompiled version of the eggie I ran (v1.6.18) and still.. no luck!

after isolating the problem, and then making a quick "test script" for exec, the eggie simply reports "TCL error- command "exec" not found" and dumps.. (in a "catch" it doesn't do anything except return "error=1")

(re)installing TCL 8.4 and then TCL8.5 didn't fix the problem...

I'm sure its something simple I'm overlooking- but, at this point I'm just too flustered to think straight! (been under too much stress just getting this thing back online!)

-DjZ-
:/ :/

EDIT!
when I mentioned above "previous version", I meant to say "previous version of TCL, AND the old non-recompiled version of the eggie" sorry for the confusion (thats what I get for posting before getting sleep)
Last edited by dj-zath on Sat Sep 11, 2010 5:38 pm, edited 4 times in total.
d
dj-zath
Op
Posts: 134
Joined: Sat Nov 15, 2008 6:49 am
Contact:

Post by dj-zath »

Okay!

after about 13 hours of sleep, I looked more closely at the problem...


Tcl error in file 'Bot.cfg':
couldn't create error file for command exec: no such file or directory
while executing
"exec ./test.cmd"
(file "./test.tcl" line 3)
invoked from within
"source "./test.tcl""
invoked from within
"if {([file exists "./test.tcl"])} {
source "./test.tcl";
}"


The problem is that I have the "exec" command mis-formatted somehow throughout my code (and even in this test script!) which, is a "realitive" example of how "exec" was used throughout my code..

example:

Code: Select all

## Get Stream Data ##

if {([catch {set CastInfo [exec fetch -q -A -m -T 1 -o - "http://$CastLogin:$CastPass@$CastIP:$CastPort/admin/icestatus.xml"];}])} {
    incr CastErr;
    if {($CastErr == "4")} {
        set DetMC "offair.gif";
        set CastInfo "";
    } elseif {($CastErr > "4")} {
        set CastErr "5";
    };
} else {
    set CastErr "0";
    set DetMC "onair.gif";
    set VarA [string first "\<icestatus\>" $CastInfo];
    set VarA [string range $CastInfo $VarA [string length $CastInfo]];
    set VarB [string first "\<\/icestatus\>" $VarA];
    set VarB [expr $VarB - "1"];
    set CastInfo [string range $VarA "11" $VarB];
};
"exec" in ths example runs "fetch" which is used to deal with authentication and socket housekeeping instead of having TCL do it (and thus slowing things way down). although this piece of code ran flawlessly in version 1.6.18 under TCL 8.4, it NO LONGER WORKS in version 1.6.20!

I was able to get an "exec" command to work in the test script by adding a &, but I can no-longer import stdout (from the fetch) into the code- and thus, is what causing the "exec failure" I am going back and re-reading the TCL man pages a little more closely to see if somehow, I was "broken" before, and now its "fixed" and no-longer working.. I now suspect its more of a "formatting/sintax" error than anything else.. and thus, IS fixable- beit it will take some work..

For this post, I changed the mode to "solved" since I was able to get the exec command to function- even though its not functioning as I need it to.. I will continue to work on this and find out what the <BEEEEP> I was doing wrong in the first place.

-DjZ-
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Had you actually said that the error message was "unable to create error file..." rather than "command not found", I could've easily pointed you to a post of mine some time ago regarding the issue.

Nevertheless; yes, you can bypass this by running the child process in bg - which eliminates the need for an "error file". However, as you noticed, you then loose any generated output. The solution instead, is to redirect stderr somewhere else, yet leaving stdout untouched.. This way, we still get the stdout output without the need for an error file.

Code: Select all

exec ./text.cmd 2> /dev/null
NML_375
d
dj-zath
Op
Posts: 134
Joined: Sat Nov 15, 2008 6:49 am
Contact:

Post by dj-zath »

hi there my ole friend, mr. nml!

yeah, I see things a LOT differently, now, after getting some much-needed sleep.. than before.. I didn't read the error output correctly initially...

I'm currently working on:

exec -- >/dev/null ./Bot.fch -q -A -m -T 1 -o - "http://macomb.com/index.html"

in the test script to see if I can get it working.. thanks for your reply in any event, I am on the idea you have stated nonetheless.. I appreciate your reply! :-)
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

First off, the redirect has to be "2>" not ">". Secondly, it has to be the last option on the command line.
NML_375
d
dj-zath
Op
Posts: 134
Joined: Sat Nov 15, 2008 6:49 am
Contact:

Post by dj-zath »

this is the command I used....

Code: Select all

exec -- fetch -q -A -m -T 1 -o - "http://$CastLogin:$CastPass@$CastIP:$CastPort/admin/icestatus.xml" 2>/dev/null &];
The problem is the Stdout is being read BEFORE the port can respond.. thus it returns a BLANK STRING

its important that the command waits for the port to read and then close.
(blocking?)

if/when the socket is fast, it works.. but this isn't constsant, I'm afraid.. running this in async isn't reliable.

-DjZ-
:/ :/
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Don't use &...
NML_375
d
dj-zath
Op
Posts: 134
Joined: Sat Nov 15, 2008 6:49 am
Contact:

Post by dj-zath »

right... then it doesn't work at all- reports "can't create error...." etc etc etc
d
dj-zath
Op
Posts: 134
Joined: Sat Nov 15, 2008 6:49 am
Contact:

Post by dj-zath »

DING DING DING!

I think I got it....


I had to do TWO changes to each instance....

Code: Select all

[catch {exec -- fetch -q -A -m -T 1 -o - "http://$CastLogin:$CastPass@$CastIP:$CastPort/admin/icestatus.xml" 2>/dev/null};]
although nml said to add "2>/dev/null" at the end of each instance, I had some where ">& /dev/null" was instead.. I now changed ALL instances to show the exact same thing as what nml stated..

I also had to add "--" after the "exec" directive AND a ; after the catch braces.. now it appears to be working...

more tests will follow...
d
dj-zath
Op
Posts: 134
Joined: Sat Nov 15, 2008 6:49 am
Contact:

Post by dj-zath »

nml.. you're a GENIUS!

looks like everythings back online could not have done it without your help!

I owe you so many beers.... :)

(I wonder if I could pay ya to rewrite this thing :-))

-DjZ-
:) :)
r
raider2k
Op
Posts: 140
Joined: Tue Jan 01, 2008 10:42 am

Post by raider2k »

btw: I like to use

Code: Select all

if { [catch { .... } error0] } {
	putlog "procname/partname - $error0"
	return 0
}
which helps out quite a lot
Post Reply