0

I am using shell script to add some file to server. Is there any way to write a shell script that will execute one part on local computer and the other part when you're logged into that server?

For example, I want to log in, do something, add some file, and then I want to list everything on that server.

ssh something@something

I enter password

Then list files from server.

Aleksandar Makragić
  • 1,957
  • 17
  • 32
  • 2
    You can append the command to run onto the ssh command as in `ssh user@host ls /remote/dir/on/host` Couple that with an SSH key, and the action is basically seamless as though you executed it locally. – Michael Berkowski Mar 13 '15 at 19:06
  • I personally use Yarek's answer here: http://stackoverflow.com/questions/305035/how-to-use-ssh-to-run-shell-script-on-a-remote-machine – Russell Uhl Mar 13 '15 at 19:47

1 Answers1

1

You can just add a command to end of the ssh command; for example:

ssh username@host ls

will run ls on the server, instead of giving you a login shell.

Brian Campbell
  • 322,767
  • 57
  • 360
  • 340