Thursday, October 3, 2013

awk run remotely

www.unixbabuforum.inI have a problem when I run the below command remotely thorugh rsh.... 
This command works fine locally on remote system... 
awk '{o=$0} /Foo.COM/ {o=o"\nDj"} {print o}' /tmp/ > /tmp/ 
But, when I run the below from another system it gives the error... 
rsh rheus awk awk '{o=$0} /Foo.COM/ {o=o"\nDj"} {print o}' /tmp/ ">" /tmp/ 
awk: Cannot find or open file /Foo.COM/.
The source line number is 1.
www.unixbabuforum.inrsh rheus awk (awk '{o=$0} /Foo.COM/ {o=o"\nDj"} {print o}' /tmp/ ">" /tmp/ ) 
www.unixbabuforum.inI would put all the awk code into a file on the remote system, 
and then do something like ... 
rsh remote_machine "awk -f awk_script >awk_script.log" 

It would be easier to debug since singles, braces, and doubles quotes (and all that stuff) are in the script, not in the command line.www.unixbabuforum.inTry this,  : 
rsh rheus "awk "\'{o=\$0} /Foo.COM/ {o=o\"\nDj\"} {print o}\'" /tmp/ > /tmp/"


Post a Comment

Design by BABU | Dedicated to grandfather | welcome to BABU-UNIX-FORUM