Harold, (bottom posted) -----Original Message----- From: hdan [mailto:[EMAIL PROTECTED] Sent: Thursday, April 22, 2004 1:54 PM To: Jayakumar Rajagopal Cc: hdan; [EMAIL PROTECTED] Subject: Re: backtick variable substitution
Thanks. I've tried that, but it didn't work. I've also tried using exec and system instead of backticks. I tried using eval, too, although I wasn't sure where to put it in the statement. -harold Jayakumar Rajagopal wrote: 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. [Jayakumar Rajagopal] +++++++++++++++++++++++ Please let me know if you can run whatever inside the backticks in shell ( unix prompt). Jay