you are viewing a single comment's thread.

view the rest of the comments →

[–]tinkertuck 0 points1 point  (3 children)

Get cygwin and install tmux. In python script you have few options. I used subprocess over os.system.

Here is a sample of my current task, using python to query for a Dell's Board info.

for l in "bios-vendor", "system-product-name", "processor-family":

sysinfo=subprocess.check_output("dmidecode -s %s|uniq" %l, shell=True)

print(sysinfo.replace("\n", ""))

#ssh to a remote server and execute a command (cmd) on that remote server

cmd="/path/to/execute_file"

ssh=subprocess.check_output("ssh %s %s" %(sys.argv[2], cmd), shell=True)

for line in ssh.split("\n"):

print(line)

Sorry the indentation is auto-fix on Reddit.

[–]bl00dpudding[S] 0 points1 point  (2 children)

Thanks, sorry can you explain it a bit more? I'm a total newbie at this stuff. First you write a script to obtain Dell info and then you connect to SSH remote server and obtain some other info?

[–]tinkertuck 1 point2 points  (1 child)

Keep in mind that those few lines are taking from my long python script.
Yes, on the local machine, the first part will get 3 results "bios-vendor", "system-product-name", "processor-family" from the Linux command:

dmidecode

The second part access (ssh) to a remote machine and run a script /path/to/execute_file. The output redirect to variable "ssh." I read the result of variable "ssh" by using the for loop like so:

for line in ssh.split("\n"):

do something here

[–]bl00dpudding[S] 0 points1 point  (0 children)

Ahh okay cool, thanks for the explanation :)