LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   rsh command issue (https://www.linuxquestions.org/questions/linux-newbie-8/rsh-command-issue-4175452224/)

jpollard 03-02-2013 09:51 AM

Quote:

Originally Posted by vicky007aggrwal (Post 4902927)
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

+++++++++++++++++++++++++++++++++++++
DIR_LOCATION=$1
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:
Code:

DIR_LOCATION=$1
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:

Code:

DIR_LOCATION=$1
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).

jpollard 03-02-2013 09:56 AM

A separate issue is still the security. If you are using the base rsh, then the connection is unencrypted and insecure (.rhosts suck at security).

If you are using rsh with Kerberos for authentication (and encryption is available as well) then there is no problem with rsh.


All times are GMT -5. The time now is 02:47 AM.