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.

2
  • 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. Commented Mar 13, 2015 at 19:06
  • I personally use Yarek's answer here: stackoverflow.com/questions/305035/… Commented Mar 13, 2015 at 19:47

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.