AWK - Cannot find or open file
am 08.10.2007 20:40:17 von bnsarma
Greetings
Trying to run awk on a remote file: app.log
OS: AIX, HP-UX, SUN
Getting the following error
/usr/bin/rsh -l oracle my_server "awk -v prev="$start" -v last="$end"
'$0 ~ prev,$0 ~ last' /u001/app.log"
awk: 0602-533 Cannot find or open file 8.
The source line number is 1.
Same problem with SSH
Please advice
Regards & Thanks
BN
Re: AWK - Cannot find or open file
am 09.10.2007 01:45:01 von Bill Marcum
On 2007-10-08, BN wrote:
> Greetings
>
> Trying to run awk on a remote file: app.log
>
> OS: AIX, HP-UX, SUN
>
> Getting the following error
>
> /usr/bin/rsh -l oracle my_server "awk -v prev="$start" -v last="$end"
> '$0 ~ prev,$0 ~ last' /u001/app.log"
> awk: 0602-533 Cannot find or open file 8.
> The source line number is 1.
>
> Same problem with SSH
>
The variables $start and $end are not quoted. You could change it to
"awk -v prev=\"$start\" -b last=\"$end\" '$0 ~ prev,$0 ~ last' /u001/app.log"
Re: AWK - Cannot find or open file
am 09.10.2007 04:17:41 von Barry Margolin
In article <1191868817.245898.235340@y42g2000hsy.googlegroups.com>,
BN wrote:
> Greetings
>
> Trying to run awk on a remote file: app.log
>
> OS: AIX, HP-UX, SUN
>
> Getting the following error
>
> /usr/bin/rsh -l oracle my_server "awk -v prev="$start" -v last="$end"
> '$0 ~ prev,$0 ~ last' /u001/app.log"
> awk: 0602-533 Cannot find or open file 8.
> The source line number is 1.
>
> Same problem with SSH
Why are you unquoting around $start and $end? Try:
Another problem is that $0 in the awk argument will be expanded locally,
being replaced with the name of the script that this is in, so you need
to escape it:
/usr/bin/rsh -l oracle my_server "awk -v prev='$start' -v last='$end'
'\$0 ~ prev,\$0 ~ last' /u001/app.log"
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***