-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathruncommand.py
More file actions
47 lines (34 loc) · 872 Bytes
/
runcommand.py
File metadata and controls
47 lines (34 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#@author dposch
import os
import sys
import paramiko
import ssh_lib as ssh
import node_parser as np
MNG_PREFIX = "192.168.0."
EMU_PREFIX = "192.168.1."
PI_START_SUFFIX = 10
PI_END_SUFFIX = 29
print "Running command:"
SRC_FILE = ""
DEST_FILE = ""
USER = ""
PASSWD = ""
if len(sys.argv) != 4:
print "Invalid Parameters -- Usage:"
print "script, user, passwd"
exit(-1)
cmd = str(sys.argv[1])
USER = str(sys.argv[2])
PASSWD = str(sys.argv[3])
# available pis: PREFIX.NR = IP
pi_list = range(PI_START_SUFFIX,PI_END_SUFFIX+1) # returns [start, ..., end-1]
print "Available PIs(" + str(len(pi_list)) + "): " + str(pi_list)
pi_ips = []
for i in pi_list:
pi_ips.append(MNG_PREFIX+str(i))
for pi in pi_ips:
print "Running command: " + cmd + " on " + pi + "."
s = ssh.Connection(pi, USER , password = PASSWD)
s.execute(cmd)
s.close()
print "Runlevel updated!\n"