Originally Posted by vicky007aggrwal
thanks everyone for your help, jpollard your suggestion worked when i used the single quotes with back ticks in my rsh command
i have one last issue now, let me explain my scenario to clear out the confusion , i am invoking below command
rsh -l <username> <machinename> 'cd $DIR_LOCATION; ps -aef | grep `pwd` | grep -v grep| grep -i catalina;echo $?'
now what is happening is that $DIR_LOCATION variable is not getting replaced with its value as i am using single quotes but the irony the back tick only works in single
quotes. I tried using doube quotes in place of single but then the command in back tick is not getting executed.
we have one legacy application which is been configured with rsh oonly not ssh,thats why i have to go with that only
Please please share your thoughts & help me in resolving this issue
thanks again for your time.
Apologies for missing that-
Try the command:
rsh -l <username> <machinename> "cd $DIR_LOCATION; ps -aef | grep \`pwd\` | grep -v grep| grep -i catalina;echo \$?"
The "\" construct is to escape the special characters and cause the local bash interpreter to treat them as just any other character (the "\" is removed during local parsing, so it doesn't appear on the remote system). But if you are sending "DIR_LOCATION" to the remote system, then using pwd to get the working directory would seem to be redundant. But then... it is possible you are trying to take into account references like "/home/../xyz" which the pwd command would drop...
If that isn't the purpose then perhaps:
rsh -l <username> <machinename> "ps -aef | grep $DIR_LOCATION | grep -v grep| grep -i catalina;echo \$?"
would work just as well (you still need the "\" on the ? for the remote status).
One last update - An advantage of this last modification is that what you are looking for doesn't HAVE to be a directory path (which may not exist in the ps listing as I indicated).