egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[SOLVED] exec command stopped working after upgrade

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
dj-zath
Op


Joined: 15 Nov 2008
Posts: 134

PostPosted: Fri Sep 10, 2010 4:58 pm    Post subject: [SOLVED] exec command stopped working after upgrade Reply with quote

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.1Cool 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
Back to top
View user's profile Send private message Visit poster's website
dj-zath
Op


Joined: 15 Nov 2008
Posts: 134

PostPosted: Sat Sep 11, 2010 12:05 pm    Post subject: Reply with quote

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:

## 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-
Back to top
View user's profile Send private message Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sat Sep 11, 2010 12:25 pm    Post subject: Reply with quote

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:
exec ./text.cmd 2> /dev/null

_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
dj-zath
Op


Joined: 15 Nov 2008
Posts: 134

PostPosted: Sat Sep 11, 2010 12:40 pm    Post subject: Reply with quote

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! Smile
Back to top
View user's profile Send private message Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sat Sep 11, 2010 1:20 pm    Post subject: Reply with quote

First off, the redirect has to be "2>" not ">". Secondly, it has to be the last option on the command line.
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
dj-zath
Op


Joined: 15 Nov 2008
Posts: 134

PostPosted: Sat Sep 11, 2010 2:42 pm    Post subject: Reply with quote

this is the command I used....

Code:

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-
:/ :/
Back to top
View user's profile Send private message Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sat Sep 11, 2010 2:51 pm    Post subject: Reply with quote

Don't use &...
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
dj-zath
Op


Joined: 15 Nov 2008
Posts: 134

PostPosted: Sat Sep 11, 2010 3:10 pm    Post subject: Reply with quote

right... then it doesn't work at all- reports "can't create error...." etc etc etc
Back to top
View user's profile Send private message Visit poster's website
dj-zath
Op


Joined: 15 Nov 2008
Posts: 134

PostPosted: Sat Sep 11, 2010 4:07 pm    Post subject: Reply with quote

DING DING DING!

I think I got it....


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

Code:
[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...
Back to top
View user's profile Send private message Visit poster's website
dj-zath
Op


Joined: 15 Nov 2008
Posts: 134

PostPosted: Sat Sep 11, 2010 4:43 pm    Post subject: Reply with quote

nml.. you're a GENIUS!

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

I owe you so many beers.... Smile

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

-DjZ-
Smile Smile
Back to top
View user's profile Send private message Visit poster's website
raider2k
Op


Joined: 01 Jan 2008
Posts: 140

PostPosted: Mon Sep 13, 2010 3:27 am    Post subject: Reply with quote

btw: I like to use
Code:

if { [catch { .... } error0] } {
   putlog "procname/partname - $error0"
   return 0
}


which helps out quite a lot
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber