weyhei
weyhei

Reputation: 479

use SSH over Python

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.

Upvotes: 0

Views: 580

Answers (2)

adahlin
adahlin

Reputation: 126

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.

Upvotes: 1

Karmel
Karmel

Reputation: 3472

import subprocess
subprocess.check_call(
    '''ssh [email protected] 'DISPLAY=:0 notify-send "{0}" "{1}"' '''.format(title, description),
    shell=True)

Upvotes: 2

Related Questions