0

How do I run this SSH on a python script?

ssh [email protected] 'DISPLAY=:0 notify-send "Title" "Description"'

My python script will ask for a raw_input() for the Title, and another one for the Description. Then the python will run the SSH inserting the Title and Description typed by the user.

1
  • Take a look at Fabric. Commented Apr 1, 2013 at 14:53

2 Answers 2

2
import subprocess
subprocess.check_call(
    '''ssh [email protected] 'DISPLAY=:0 notify-send "{0}" "{1}"' '''.format(title, description),
    shell=True)
Sign up to request clarification or add additional context in comments.

2 Comments

And don't forget to properly escape your input if it comes from the user :)
How do I properly escape the input? I mean it keeps getting error when using apostrophes.
1

If you're going to want a little more control, you should also check out the paramiko library: https://github.com/paramiko/paramiko It's an SSH2 library for python.

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.