1

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
Experiment_A

Local Server

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

(Output)

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

ritupanda
  • 13
  • 4
  • 2
    SCP can copy recursively. man scp | less +/\ -r. – 41754 Aug 27 '19 at 07:55
  • 1
    Define unable to ? – tink Aug 27 '19 at 07: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 08:18
  • Your screen session is almost certainly connected via ssh. Just scp the directory over. – Wildcard Aug 27 '19 at 08: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 08:27
  • The screen session and scp are independent. Ignore screen and use scp to copy your files, or maybe sftp. – Jojje Aug 27 '19 at 08:34
  • the address of my remote server is xxxx@i.p.address. i start a screen session, and then the host name changes to root@xxxxx. The folders within this session are not present anywhere when i detach from the session. – ritupanda Aug 27 '19 at 08:35
  • scp ritu@xx.xx.xx.xxx screen -r 34502.pts-0.xxxx:/media/Experiment_A/features /Users/local/ExpResult

    (output) scp: /media/Experiment_A/features: No such file or directory


    This folder is present in the root folder within the screen session but not outside.

    – ritupanda Aug 27 '19 at 08:39
  • What is the output of pwd; ls -ld . immediately after you do screen -r ...`? – ctrl-alt-delor Aug 27 '19 at 11:11

2 Answers2

1

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.

  • Thank you so much! I will try this. – ritupanda Aug 27 '19 at 08: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
1

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.

Kusalananda
  • 333,661