| View previous topic :: View next topic |
| Author |
Message |
BCyo+8C4 Voice
Joined: 03 Sep 2006 Posts: 24
|
Posted: Sun Sep 03, 2006 11:20 am Post subject: exec awk problem |
|
|
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 |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Mon Sep 04, 2006 12:13 am Post subject: |
|
|
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 |
|
 |
BCyo+8C4 Voice
Joined: 03 Sep 2006 Posts: 24
|
Posted: Mon Sep 04, 2006 6:33 am Post subject: |
|
|
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 |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Mon Sep 04, 2006 12:42 pm Post subject: |
|
|
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 |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Mon Sep 04, 2006 2:24 pm Post subject: |
|
|
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 |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Mon Sep 04, 2006 2:26 pm Post subject: |
|
|
| 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 |
|
 |
BCyo+8C4 Voice
Joined: 03 Sep 2006 Posts: 24
|
Posted: Tue Sep 05, 2006 10:21 am Post subject: |
|
|
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 |
|
 |
|