Go Back   The UNIX and Linux Forums > Operating Systems > AIX
.
google site




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 06-13-2009
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,670
The reason for your problem is the command evaluation process in ksh. You might want to read what i have written for a different (but related) problem here.

Your commandline is first interpreted locally and the content of the variable is filled in and protected by the double quotes. Now a remote connection is opened and the rest of the line is passed as command line to the remote shell interpreter. Guess what? At the remote site the commandline is getting interpreted *again* and now the double quotes are not there any more because they are already "used". The command will look like this (first line=local, second line=remote):


Code:
rsh host grep ^Sat Jun 13 06:19:07 CEST 2009 file
              --------one argument-----
grep ^Sat Jun 13 06:19:07 CEST 2009 file

And of course "grep" will try to find "^Sat" is a file called "Jun", which leads to the error.

The solution is to protect your double quotes by escaping them:


Code:
rsh host grep "\"$xx\"" file

I hope this helps.

bakunin