scp to invoke files stored in environment variable
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
scp to invoke files stored in environment variable
Hi,
I need to a file temp.txt from a remote computer to my local system.The remote system has files stored in an environmental variable $LOGDATA. But when I use this in scp $LOGDATA/temp.txt, it says LOGDATA: No such file or directory. What has to be written in order to retrieve the file?
Are you issuing the scp command on the remote system or the local system? It seems that $LOGDATA is not defined in the context in which you are trying to execute the command...
I have written scp in a java program where I am creating a form to take the username, password and the required file to be retrieved from the remote system as input.
I have not defined $LOGDATA anywhere in the java program. If it is required, where do I define it?
Moreover I give $LOGDATA as input during runtime. If that is the case I won't be able to define it.
Should I attach the code?
Last edited by shik28; 09-15-2011 at 10:42 AM.
Reason: content missing
i dont know. from your first post LOGDATA seemed like a variable specific to your site. no one else can tell you what it should be. maybe the admin of the server can tell you.
if you are unable to scp successfully from the command line then your java-gui wrapper will never work.
i would check the basics:
are you sure the ssh service is running on the remote machine ?
are you sure that the local file exists ?
are you sure that the remote directory exists ?
...
can you please copy-and-paste the command you are trying to run and the error you are getting (you do realize we cant see your screen <@).
When I get it right, $LOGDATA is defined for you when you ssh to the remote machine. I.e. it’s a variable only known on the remote side, but not when you include it in the local scp command. So it must be executed on the remote side instead:
Code:
$ ssh -C server cat \$LOGDATA/temp.txt | cat > temp.txt
I added -C to compress the file during the transfer.
i would check the basics:
are you sure the ssh service is running on the remote machine ?
are you sure that the local file exists ?
are you sure that the remote directory exists ?
...
can you please copy-and-paste the command you are trying to run and the error you are getting (you do realize we cant see your screen <@).
1. Yes, I am sure that ssh service is running on the remote machine because the code works fine if I try to retrieve files from the root directory.
2. This code creates the local file if it doesn't exist. So that is not an issue.
3. Remote directory doesn't exist but all the files are stored in $LOGDATA
$LOGDATA is shell var and only exists in the context of the process that created it AND is still running.
It cannot be a remote var, as you cannot read the vars created by another process...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.