Operating System - HP-UX
1753792 Members
7301 Online
108799 Solutions
New Discussion юеВ

Re: scp/rcp and remote env variables

 
Avinash20
Honored Contributor

scp/rcp and remote env variables

When I am doing scp/rcp from local to remote server or vice versa, the local env variables are taken in consideration.

Is it possible for scp/rcp to take the env remote variables

eg:
Local: shivalik
Remote: shivaji

When I am trying to copy a file from a remote server to a local directory using scp, I am getting the following error.

shivalik>#scp shivaji:$HOME/hosts $HOME/hosts1
Password:
scp: /tmp/shivalik/hosts: No such file or directory

shivalik>#rcp shivaji:$HOME/hosts $HOME/hosts1
rcp: /tmp/shivalik/hosts: No such file or directory

shivalik># echo $HOME
/tmp/shivalik

shivalik># ls /tmp/shivalik
passwd

shivaji># echo $HOME
/tmp/shivaji

shivaji># ls /tmp/shivaji
hosts

SO you see here its taking the local variable

Is it possible in anyways to take the remote variable via scp/rcp
"Light travels faster than sound. That's why some people appear bright until you hear them speak."
12 REPLIES 12
Patrick Wallek
Honored Contributor

Re: scp/rcp and remote env variables

How is it supposed to know what the remote variables values are? scp/rcp DO NOT execute a .profile or any login script. They establish a connection to the remote server only.

There **MIGHT** be something that you can do via ssh.config or sshd.config, but I don't know of anything off hand.

Avinash20
Honored Contributor

Re: scp/rcp and remote env variables

Thanks..

You are right. It won't execute the .profile while we are doing scp/rcp

I like to know if there are any options available or any configuration needs to be done..
"Light travels faster than sound. That's why some people appear bright until you hear them speak."
Steven Schweda
Honored Contributor

Re: scp/rcp and remote env variables

Why specify "$HOME" anywhere?
Avinash20
Honored Contributor

Re: scp/rcp and remote env variables

Hi Steven,

Thanks for your reply.

It not only with only one variable $HOME.

My query is how is it possible to do scp/rcp by defining remote env. variable as provided in the above question

Local variables works fine, its only that the remote variable are not taken into consideration !!

Is it possible, and if yes, then how.
"Light travels faster than sound. That's why some people appear bright until you hear them speak."
Venkatesh BL
Honored Contributor

Re: scp/rcp and remote env variables

May be you can define a local env variable for the remote directory as well...

#scp shivaji:$REMOTE_HOME/hosts $HOME/hosts1
Avinash20
Honored Contributor

Re: scp/rcp and remote env variables

Hi,

thanks for your reply,

As told earlier, this works fine when local variable are defined.
"Light travels faster than sound. That's why some people appear bright until you hear them speak."
Steven Schweda
Honored Contributor

Re: scp/rcp and remote env variables

If you want a variable to be evaluated at
the remote end, then you would need to keep
the local shell from evaluating it. For
example:

scp shivaji:'$HOME/hosts' $HOME/hosts1

But that won't help if the program at the
other end does not try to evaluate the
variable. I don't know what will happen
with scp.

You might do better with a "tar" pipeline and
SSH, where the command for the remote end
includes the (quoted) variables.
Avinash20
Honored Contributor

Re: scp/rcp and remote env variables

??

shivalik> scp shivaji:'$HOME/hosts' .
rcp: //hosts: No such file or directory

### Let me check with one of my customer who claims its possible & is working fine at his site on one of his HP-UX server.
"Light travels faster than sound. That's why some people appear bright until you hear them speak."
Steven Schweda
Honored Contributor

Re: scp/rcp and remote env variables

> shivalik> scp shivaji:'$HOME/hosts' .
> rcp: //hosts: No such file or directory

If you're using "scp", why does the complaint
say "rcp"?

"//hosts" makes it look as if "$HOME" was
"/", which is not what I'd expect if HOME
were undefined.

This might make more sense if you did less
editing of the transcript showing what you
did, and what happened when you did it.