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.

exec awk problem with quotes

Help for those learning Tcl or writing their own scripts.
Post Reply
B
BCyo+8C4
Voice
Posts: 24
Joined: Sun Sep 03, 2006 11:11 am

exec awk problem with quotes

Post by BCyo+8C4 »

Hi,
I need a tcl to start awk like this:

Code: Select all

awk -f alfa.awk -v was="array('$mask'" bans-$chan.txt >bans-$chan-tmp.txt
But when I put it in my script (after exec) like that it complains about "extra characters after close-quote"

If I escape them (\") I get: Invalid command name """

I also tried this but that failed as well:

Code: Select all

set varname "awk -f alfa.awk -v was=\"array('$mask'\" bans-$chan.txt >bans-$chan-tmp.txt"
eval exec $varname
What's the correct way to escape those quotation chars?
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

set awk [list awk -f alfa.awk -v was="array('$mask'" bans-$chan.txt >bans-$chan-tmp.txt]
eval exec $awk
Encapsulate your arguments within
  • evaluation. See if that helps.
    <speechles> .tcl set a [list awk -f alfa.awk -v was="array('mask'" bans-chan.txt >bans-chan-tmp.txt]
    <bot> Tcl: awk -f alfa.awk -v was=\"array('mask'\" bans-chan.txt >bans-chan-tmp.txt
    * I had to strip the $ from your variables as I don't have those set *
    * It would've worked with them if I had those set... *
B
BCyo+8C4
Voice
Posts: 24
Joined: Sun Sep 03, 2006 11:11 am

Post by BCyo+8C4 »

that doesn't work either.
while there's no error in console now the file is simply not changed, it's like awk didn't run at all.

example "bans-chan.txt":

Code: Select all

); ?>
example tcl:

Code: Select all

set awk [list awk -f alfa.awk -v was=");" bans-chan.txt >bans-chan-tmp.txt] 
eval exec $awk
the awk command itself is correct as it works in shell


EDIT: Well, never mind I guess, I found another solution (without using awk)
Post Reply