I have been running my code within a screen session on a remote server. I want to move the output directories generated within this session on the remote server to my local server using SCP but I am not able to.

  1. Is there a way to do this?

  2. If not, how can I copy my folders from the screen session to my remote server (so that I can SCP to my local server)?

Currently, this is what I do.

ssh ritu@i.p.address
ritu@i.p.address$ screen -r xxxx.pt
root@xxxxxx# ls media

Local Server

scp ritu@xx.xx.xx.xxx:/media/Experiment_A/features /Users/local/ExpResult


scp: /media/Experiment_A/features: No such file or directory

  • 2
    SCP can copy recursively. man scp | less +/\ -r. – 41754 Aug 27 '19 at 7:55
  • 1
    Define unable to ? – tink Aug 27 '19 at 7:59
  • i can access the output folders only when i attach to screen session. the folder is not stored in the server from where i am running the screen. – ritupanda Aug 27 '19 at 8:18
  • Your screen session is almost certainly connected via ssh. Just scp the directory over. – Wildcard Aug 27 '19 at 8:26
  • 4
    The filesystem (which holds the directories) is totally independent of your screen session. There is no difference between files and directories in the screen session and outside of it. You must clarify what you are trying to do and show exactly what commands you use to copy the files and what error message you get. – Kusalananda Aug 27 '19 at 8:27

It looks like you are re-attacing to a session started by root. The files may be in /root.

Where ever they are you may have to change the file permissions to be able to read them. see What are the different ways to set file permissions etc on gnu/linux

They may also be on a mount-point that is restricted to a single user. If so then if the files are small, then copy them to yourself on the remote machine, then scp.

| improve this answer | |
  • Thank you so much! I will try this. – ritupanda Aug 27 '19 at 8:58
  • So what was the problem? How did you fix it? – ctrl-alt-delor Aug 27 '19 at 11:12
  • I use the vm to run a docker container. While mounting the docker, it was aliased to another folder and within the screen session I was storing my folders in another location. This was first time working on a docker container and it has been a few months since I setup the environment. I didnt remember which file was the mounting aliased to. – ritupanda Aug 27 '19 at 11:31

I looks as if you got the path ever so slightly wrong in your scp command.

The following should work:

scp ritu@xx.xx.xx.xxx:media/Experiment_A/features /Users/local/ExpResult

Explanation: When you log into the remote machine, you end up in your home directory. This is most likely /home/username (where username is your username). In your home directory, you have that media subdirectory.

In the scp command, if you specify a relative path, i.e. a path that does not start with /, that path will be relative to your home directory. Therefore, by just removing the / from the path that you used in your command, you get a path that is most likely correct for copying your media/Experiment_A/features file.

If this does not work, it is because the screen session has changed its current directory to someplace else. What you could do then is to issue the command pwd in the session and then use the path that this outputs in your scp command.

The other thing to try is to execute scp on the remote machine to transfer the file to the local machine. This would obviously only work if you are allowed to log in locally from that machine using SSH.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.