HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

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
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.
Avinash20
Honored Contributor

Re: scp/rcp and remote env variables

Sorry.. I might have done scp and rcp and for formatting the lines might have got deleted.

Apologies for the same !!

#uname -a
HP-UX shivalik B.11.23 U ia64 3360995785 unlimited-user license
#echo $HOME
/tmp/shivalik

#cat /.profile| grep HOME
export HOME=/tmp/shivalik

#ls /tmp/shivalik
.sw passwd

#scp shivaji:'$HOME/hosts' $HOME/hosts1
Password:
scp: //hosts: No such file or directory
#rcp shivaji:'$HOME/hosts' $HOME/hosts1
rcp: //hosts: No such file or directory


# uname -a
HP-UX shivaji B.11.11 U 9000/811 2007026426 unlimited-user license
# echo $HOME
/tmp/shivaji
# cat /.profile | grep HOME
export HOME=/tmp/shivaji

# ls /tmp/shivaji
.sw hosts

## This could also simulate the same issue on the server

## Take two server, and ty to do the same.
"Light travels faster than sound. That's why some people appear bright until you hear them speak."
Avinash20
Honored Contributor

Re: scp/rcp and remote env variables

Still can't succeed..
Not sure how is it possible
"Light travels faster than sound. That's why some people appear bright until you hear them speak."
Avinash20
Honored Contributor

Re: scp/rcp and remote env variables

Patrick was right.. I was trying something which will take some more research
Thanks everyone
"Light travels faster than sound. That's why some people appear bright until you hear them speak."