shell - Python script to access a host with ssh and run commands in the host -


i trying write python script allow me ssh host, run curl command, , parse output of command.

i trying

os.system('ssh host') os.system('curl ...') 

however, curl command not execute on server. server have no connection python script anymore. need able execute curl command , access output can parse it. ideas how can accomplish this? thanks.

to access output of command run , use subprocess module. gives lot of control on os commands run. here code snippet.

import subprocess process_object = subprocess.popen(['cat','myfile.txt'],stdout=subprocess.pipe , stderr = subprocess.stdout) ; output = process_object.stdout.read() 

likewise use ['ssh','host','argument2','argument3'] implementation. i'm not sure if fixes curl not executing problem. helps output .


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -