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 

exec awk problem

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
BCyo+8C4
Voice


Joined: 03 Sep 2006
Posts: 24

PostPosted: Sun Sep 03, 2006 11:20 am    Post subject: exec awk problem Reply with quote

Hi,
I'd like to call awk from a tcl script, but for some reason it doesn't work. No error message returned.

In my tcl I have this line to call the script:
Code:
exec awk -f alfa.awk -v was='{tr}{td}$mask' bans-$chan.txt > bans-$chan-tmp.txt


All parameters are send to the script correctly and the awk command works fine like this when called from bash.
Changing the script to point to an invalid .awk file makes it throw an error, so it seems awk is actually run. It just doesn't do what it's supposed to do when called from tcl.

Anyone got an idea what I got wrong?
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Mon Sep 04, 2006 12:13 am    Post subject: Reply with quote

escape curly braces with backslashes
_________________
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code
Back to top
View user's profile Send private message Visit poster's website
BCyo+8C4
Voice


Joined: 03 Sep 2006
Posts: 24

PostPosted: Mon Sep 04, 2006 6:33 am    Post subject: Reply with quote

the problem is not the brackets, even this test code doesn't work when called from tcl:
Code:
exec awk -f alfa.awk -v was='test' bans-#test.txt > bans-#test-tmp.txt
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Mon Sep 04, 2006 12:42 pm    Post subject: Reply with quote

my guess is that space between the redirection character and output file name is not being interpreted as in shell

try without it, i.e. >bans-$chan-tmp.txt
_________________
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code
Back to top
View user's profile Send private message Visit poster's website
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Mon Sep 04, 2006 2:24 pm    Post subject: Reply with quote

Tcl Built-In Commands - exec manual page

If an arg (or pair of args) has one of the forms described below then it is used by exec to control the flow of input and output among the subbprocess(es). Such arguments will not be passed to the subprocess(es). In forms such as ``< fileName'' fileName may either be in a separate argument from ``<'' or in the same argument with no intervening space (i.e. ``<fileName'').


> fileName
Standard output from the last command is redirected to the file named fileName, overwriting its previous contents.
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Mon Sep 04, 2006 2:26 pm    Post subject: Reply with quote

BCyo+8C4 wrote:
the problem is not the brackets, even this test code doesn't work when called from tcl:
Code:
exec awk -f alfa.awk -v was='test' bans-#test.txt > bans-#test-tmp.txt


Just curious, what does your awk script try to accomplish and why could it not be done in native tcl code?
Back to top
View user's profile Send private message
BCyo+8C4
Voice


Joined: 03 Sep 2006
Posts: 24

PostPosted: Tue Sep 05, 2006 10:21 am    Post subject: Reply with quote

got it. it was the ' chars + the space after >

working code:
Code:
exec awk -f alfa.awk -v was={tr}{td}$mask bans-$chan.txt >bans-$chan-tmp.txt
exec mv bans-$chan-tmp.txt bans-$chan.txt
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