Hi hdan,
try \$ for $.
I did not test it anyway.
HTH,
Jay

-----Original Message-----
From: hdan [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 22, 2004 1:13 PM
To: [EMAIL PROTECTED]
Subject: backtick variable substitution


Hi all,

Hopefully someone can help me out with this one.

I have a perl script that runs rsh commands to monitor a remote server.  
To minimize time and bandwidth I need to maximize the processing that is 
done on the remote server and minimize the number of rsh commands done.

My question is, how can I place a while loop within a system call so 
that the loop variable is substituted correctly?  Here is an example:


$THE_ERRORS =
`rsh remote_box "cat -n app_error.log | grep -E 'error' |
cut -f 1 | while read x; do head -$x app_error.log | tail -2; done"`;

Basically, I'm trying to get the error message line and the line before 
it returned into $THE_ERRORS.  The problem is that $x is not being 
interpreted correctly by the head command.

For simplicity, we can take the whole rsh out of the picture and use 
this as an example:

$THE_ERRORS =
`cat -n app_error.log | grep -E 'error' |
cut -f 1 | while read x; do head -$x app_error.log | tail -2; done`;


Thanks for any suggestions.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to