LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 09-15-2011, 06:35 AM   #1
shik28
LQ Newbie
 
Registered: Sep 2011
Location: India
Posts: 25

Rep: Reputation: Disabled
Question 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?
 
Old 09-15-2011, 10:50 AM   #2
jmulligan
LQ Newbie
 
Registered: Oct 2006
Posts: 4

Rep: Reputation: 1
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...
 
1 members found this post helpful.
Old 09-15-2011, 10:58 AM   #3
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,028

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
echo $LOGDATA mite help us determine where the issue is ?

edit: make sure you define LOGDATA in the pc you are running scp from.

Last edited by schneidz; 09-15-2011 at 10:59 AM.
 
1 members found this post helpful.
Old 09-15-2011, 11:38 AM   #4
shik28
LQ Newbie
 
Registered: Sep 2011
Location: India
Posts: 25

Original Poster
Rep: Reputation: Disabled
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 11:42 AM. Reason: content missing
 
Old 09-15-2011, 11:44 AM   #5
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,028

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
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.
 
Old 09-15-2011, 12:27 PM   #6
shik28
LQ Newbie
 
Registered: Sep 2011
Location: India
Posts: 25

Original Poster
Rep: Reputation: Disabled
Unhappy

Yes. scp is not successful from command line also. Any alternate solution?
 
Old 09-15-2011, 03:39 PM   #7
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,028

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
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 <@).

Last edited by schneidz; 09-15-2011 at 03:41 PM.
 
Old 09-15-2011, 03:52 PM   #8
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 13.1
Posts: 1,326

Rep: Reputation: 253Reputation: 253Reputation: 253
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.
 
1 members found this post helpful.
Old 09-15-2011, 09:52 PM   #9
shik28
LQ Newbie
 
Registered: Sep 2011
Location: India
Posts: 25

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by schneidz View Post
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

4. Here's the link to the code which I am trying to run: http://www.jcraft.com/jsch/examples/ScpFrom.java
 
Old 09-16-2011, 02:12 AM   #10
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
$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...
 
Old 09-16-2011, 04:41 AM   #11
shik28
LQ Newbie
 
Registered: Sep 2011
Location: India
Posts: 25

Original Poster
Rep: Reputation: Disabled
What can be done in order to retrieve those files now?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Not able to invoke variable values vjayraghavan Programming 1 05-05-2010 03:22 AM
Scripting: accessing a variable stored in a variable? tomolesonjr Linux - Newbie 5 05-05-2006 09:47 PM
Where are environment variables stored? binarybob0001 Linux - General 8 11-15-2005 09:54 PM
where are the environment variables stored? ojav Linux - Newbie 3 05-31-2005 05:00 PM
which path do the environment variable files reside in ycli00 Linux - General 1 03-03-2004 02:57 AM


All times are GMT -5. The time now is 12:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration