LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   scp on the file stored in / (https://www.linuxquestions.org/questions/programming-9/scp-on-the-file-stored-in-903956/)

shik28 09-20-2011 01:35 AM

scp on the file stored in /
 
I am logged into a remote system as shik28. I have to retrieve a file which is located in the directory /log from the remote system to the local system.

when I write execute the following command,
Code:

scp shik28@somedomain.com:/log/source.txt destination.txt
I get an error,
Code:

/log/source.txt: No such file or directory
How do I do scp of files in /?

druuna 09-20-2011 01:42 AM

Hi,

You mention being logged into the remote server and want to scp a file to your local server. If that is true, the command is wrong (it scp's from remote to local):

Code:

scp /log/source.txt user@localserver.com:/path/to/destination.txt
The command posted by you would probably work if you executed it from the local server.

Hope this helps.

shik28 09-20-2011 01:49 AM

Quote:

Originally Posted by druuna (Post 4476846)
Hi,

You mention being logged into the remote server and want to scp a file to your local server. If that is true, the command is wrong (it scp's from remote to local):

Code:

scp /log/source.txt user@localserver.com:/path/to/destination.txt
The command posted by you would probably work if you executed it from the local server.

Hope this helps.

@druuna: I tried this. I am getting the same error. Does scp have permission to retrive files from /root when I am logged in as user?

colucix 09-20-2011 02:07 AM

Nope. Usually a user hasn't got permission to access log files, but the error in that case would be "Permission denied". Check the path of the file: might it be in /var/log/ instead?

shik28 09-20-2011 02:09 AM

Quote:

Originally Posted by colucix (Post 4476868)
Nope. Usually a user hasn't got permission to access log files, but the error in that case would be "Permission denied". Check the path of the file: might it be in /var/log/ instead?

@colucix: The path is absolutely correct.

druuna 09-20-2011 02:12 AM

Hi,

As already mentioned by colucix: You do need the proper permissions, on both sides. But the error shown points to a source that doesn't exist.

Hope this helps.

druuna 09-20-2011 02:15 AM

Hi,

What is the output of the following command:

On the local and the remote server: ls -l /log/source.txt (and please specify which is which).

corp769 09-20-2011 02:20 AM

After reading through this thread, it seems the OP maybe confused now - As stated in the first post, he was logged into the remote system, trying to scp a file over to his local system. I think you want to not be logged in, and just use scp from the local computer, using the command posted in the first post, to remotely retrieve the file to avoid confusion.

druuna 09-20-2011 02:25 AM

@corp769: As stated in post #2 :)

corp769 09-20-2011 02:28 AM

Quote:

Originally Posted by druuna (Post 4476882)
@corp769: As stated in post #2 :)

Ahh, now I see it. I wanted to ask the same question you did before, but you beat me to it. This definitely sounds very simple :p

shik28 09-20-2011 02:29 AM

Command works fine now. Thanks for all your replies. :)

corp769 09-20-2011 02:30 AM

Quote:

Originally Posted by shik28 (Post 4476887)
Command works fine now. Thanks for all your replies. :)

What was your fix for the minor issue? And how did you send the file/files over? From your local computer, sending the scp command over?

shik28 09-20-2011 02:39 AM

Quote:

Originally Posted by corp769 (Post 4476889)
What was your fix for the minor issue? And how did you send the file/files over? From your local computer, sending the scp command over?

The issue has been solved for some files in /log i.e. text files. But I get the same error when I try to retrieve other files which have no extension (like: I have a file called df.last with no extension displayed).

I tried to get the file type using the following command
Code:

file /log/df.last
It says:
Code:

/log/df.last: ASCII text
So now the problem lies in getting the extension for this file. So finally my problem is partially solved. Sorry for marking the thread as [SOLVED].

colucix 09-20-2011 02:46 AM

It's not really clear how did you solve the previous problem: please, can you post the command you used to copy the file /log/source.txt? The same command would work for any other file, despite the absence of extensions. What is the error message in this case?

Furthermore, it's not clear what is your concept of file extension, since df.last has the "last" extension (even if this concept in linux is quite arbitrary).

shik28 09-20-2011 03:53 AM

Quote:

Originally Posted by colucix (Post 4476900)
It's not really clear how did you solve the previous problem: please, can you post the command you used to copy the file /log/source.txt?

Code:

scp shik28@domain1.com:/log/source.txt destination.txt
This works fine.

Quote:

Originally Posted by colucix (Post 4476900)
The same command would work for any other file, despite the absence of extensions. What is the error message in this case?

No, it is not working for one file by name df.last. Error msg is
Code:

/log/df.last: No such file or directory
Quote:

Originally Posted by colucix (Post 4476900)
Furthermore, it's not clear what is your concept of file extension, since df.last has the "last" extension (even if this concept in linux is quite arbitrary).

The file name itself is df.last. I don't know the extension. last is not an extension. It is a part of the filename.


All times are GMT -5. The time now is 02:30 AM.