Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to move files on a remote machine from folder A to folder B via ssh.

I am using this command: ssh user@server "sh scan/"

This will run a script which contains some file operations, moving files around on the remove machine. The problem is that my SSH seems to attempt to execute the contents of on my local computer.

I am using zsh.

Thanks for the help

share|improve this question

migrated from Jan 22 '12 at 9:53

This question came from our site for professional and enthusiast programmers.

Pass the -v flag to ssh to understand what is happenning – Basile Starynkevitch Jan 22 '12 at 7:17
"The problem is that my SSH seems to attempt to execute the contents of on my local computer." Is it moving the files on the remote machine? Is it moving the files on the local computer? Why do you suspect the script is being executed on the wrong computer? – dave4420 Jan 22 '12 at 10:12
up vote 6 down vote accepted

You can execute remote commands through ssh, for instance:

ssh -n user@host mv fileOnRemoteServer destination

share|improve this answer
Thank you I accepted this answer now. Works perfect. – Hendrik Feb 4 '12 at 10:59

You're on a Linux box? That should work without any problems.

Now, are you sure that the command isn't running on the remote machine, but merely displaying the output of the script on your machine? That would make it appear the script is running on your machine even though it isn't.

share|improve this answer
This was the case. Thanks! Is there any way this can be avoided? – Hendrik Jan 22 '12 at 13:55
@Hendrik - When you log in with SSH, some systems set an environment variable of SSH_CLIENT or SSH_CONNECTION. I'm Kornshell, not BASH, so I can't verify this, but might be possible to set something up in .bashrc to print a warning if one of these environment variables are set. Doesn't work in Ksh because you set the name of the environment file in .profile and ssh doesn't execute that. Give it a try and let me know. Otherwise, you'll have to put something in your scripts itself. – David W. Jan 22 '12 at 21:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .