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:
`rsh remote_box "cat -n app_error.log | grep '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:
`cat -n app_error.log | grep 'error' |
cut -f 1 | while read x; do head -\$x app_error.log | tail -2; done`;
Thanks for any suggestions.