Operating System - Linux
1753767 Members
5700 Online
108799 Solutions
New Discussion юеВ

Re: rsh failing when passing special characters as its argument

 
SOLVED
Go to solution
msbinu
Advisor

rsh failing whn passing special characters as its argument

Hi,

I hav a script hich is doing some thing like this ..
/usr/bin/rsh -n $SERVER_IP "ksh -c \"cd /opt/abc/efg/;./myscript $NODE $KEY $DISPLAY $NAME $VERSION $PATH

now if the parameter NAME is having some special character in it ( like _ , $, @ ,/) then rsh is failng

Can an one help me with this
Regards
Binu
5 REPLIES 5
Dennis Handly
Acclaimed Contributor
Solution

Re: rsh failing when passing special characters as its argument

rsh on HP-UX is the restricted shell, I assume you mean remsh?

Why are you bothering to use ksh inside a remsh? Are you worried that the user on the other side is using the scummy C shell?

You should be able to use:
remsh $SERVER_IP -n "cd /opt/abc/efg/; ./myscript $NODE $KEY $DISPLAY $NAME $VERSION $PATH"

You may have problems if $NAME has a "$" but "_" and "@" should be ok. (Unless "@" is used as erase?)

This will let you pass an embedded "$" to myscript:
$ NAME='x$x'; remsh $SERVER_IP -n "... ./myscript '$NAME' "

msbinu
Advisor

Re: rsh failing whn passing special characters as its argument

Hi Thanks a lot .. it worked ..
one more doubt .if NAME is having $ remsh will fail ?? can u pls tell me y its like this
Bill Hassell
Honored Contributor

Re: rsh failing whn passing special characters as its argument

The shell is interfering with your command line (by design). Your script needs the variables expanded but along with that expansion comes shell interpretation of the results. As always when testing these types of remote execution command lines, use echo to see what is really happening:

echo /usr/bin/rsh -n $SERVER_IP "ksh -c \"cd /opt/abc/efg/;./myscript $NODE $KEY $DISPLAY $NAME $VERSION $PATH

The echo will show you what is REALLY going to processed. If you see special characters in $NAME, then they will also be expanded and interpreted --> on the remote machine's ksh shell.


Bill Hassell, sysadmin
msbinu
Advisor

Re: rsh failing whn passing special characters as its argument

Thnks .. this helps a lot ...what will be the impact of remopving this ksh -c from my command ??? when can this casue a problem
Dennis Handly
Acclaimed Contributor

Re: rsh failing when passing special characters as its argument

>what will be the impact of removing this ksh -c from my command ???

As I said, if your remote system doesn't have the same shell.

The benefit is that you don't have to have an extra level of quoting. It took at least a few minutes to find my solution, adding more levels takes more fiddling.