0

I want to write script on python which could execute shell commands on a remote server.

I find out that I could use something like:

# set environment, start new shell
p = Popen("/path/to/env.sh", stdin=PIPE)

# pass commands to the opened shell
p.communicate("python something.py\nexit")

But I do not understand how can I login to remote Linux server and execute shell commands there?

3
  • Possible duplicate: stackoverflow.com/questions/3173977/… Commented Jun 10, 2014 at 13:07
  • @pss That one is "without actually logging in". This one is with logging in. Although the answer basically says "log in, dude". Commented Jun 10, 2014 at 13:08
  • you can use pexpect. pypi.python.org/pypi/pexpect Commented Jun 10, 2014 at 13:09

1 Answer 1

1

Look into using Paramiko or Pyro4 or fabric. All of these should do what you would like.

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.