Armin <a-steinhoff@web_.de> wrote:
Brian Stecher wrote:
Armin Steinhoff <a-steinhoff@web_.de> wrote:
there is a curious problem with rsh … the result of a remote cmd
depends
on the string quotes >
\
rsh QRTP_RACK “echo $PATH”
…
\
rsh QRTP_RACK ‘echo $PATH’
…
What’s the problem ??
Absolutely nothing.
You haven’t read care fully my posting …
You haven’t understood what is happening.
Try:
echo “echo $PATH”
echo ‘echo $PATH’
Shell quoting rules say that within double quotes, macros are still
expanded. Within single quotes, they aren’t. That means in your first
example, the $PATH is expanded on the local machine. In the second, the
$PATH is not expanded on the local machine,
It is expanded on the remote machine … but the environment is wrong.
Well trust your eyes … or do your own tests.
That isn’t what you said – you didn’t say that remote environment
was wrong, you just posted something that showed that the local and
remote environment were different.
That’s are the facts: # rsh QRTP_RACK ‘echo $PATH’
returns → /proc/boot:/bin:/usr/bin … but this
is not the PATH which fits to the environment
of the remote login.
Ah, that is a different issue – not what you initially posted.
rsh does NOT create a login shell on the remote machine. Therefor,
you will not get processing of /etc/profile and ~/.profile where
PATHs are usually set. You will get whatever path is inheritted from
io-net, probably started in boot file or soon after, that is, a
fairly minimal path.
It is not a shell problem. I have used bash and got the same behavior
of the rsh command.
It is not a shell problem. It is proper behaviour of the shell, from the
bourne sh (both ksh and bash are derivatives of sh), which is why bash
also gives the same behaviour.
but when it gets to the
remote it is (since the quotes have been processed and removed by the
local shell).
You can delay the expansion to the remote machine by also doing something
like:
rsh QRTP_RACK “echo $PATH”
There are no problems with rsh QRTP_RACK “echo $PATH” … it works
correctly.
It gives you the path on your local machine.
Before you do the double-quote version, try doing this:
export PATH=$PATH:/dir_not_in_path
rsh QRTP_RACK “echo $PATH”
You’ll find that it has /dir_not_in_path in its path.
-David
QNX Training Services
I do not answer technical questions by email.