LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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, 05: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, 09: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, 09:58 AM   #3
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
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 09:59 AM.
 
1 members found this post helpful.
Old 09-15-2011, 10: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 10:42 AM. Reason: content missing
 
Old 09-15-2011, 10:44 AM   #5
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
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, 11:27 AM   #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, 02:39 PM   #7
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
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 02:41 PM.
 
Old 09-15-2011, 02:52 PM   #8
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
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, 08: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, 01:12 AM   #10
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
$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, 03: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



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 02:22 AM
Scripting: accessing a variable stored in a variable? tomolesonjr Linux - Newbie 5 05-05-2006 08:47 PM
Where are environment variables stored? binarybob0001 Linux - General 8 11-15-2005 08:54 PM
where are the environment variables stored? ojav Linux - Newbie 3 05-31-2005 04:00 PM
which path do the environment variable files reside in ycli00 Linux - General 1 03-03-2004 01:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

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
Open Source Consulting | Domain Registration