how should i readout data from shell to python script variables.. ?

process = subprocess.Popen("rsh botham 'ps -eo fname | grep sublime'",shell=True, stdout=subprocess.PIPE)
process2= subprocess.Popen('hostname')

Recommended Answers

All 5 Replies

Docs maybe?
Or I did not understand the question.

well i have been trying this on CentOS on tsch but not getting anything into the variable output

import subprocess

process = subprocess.Popen("rsh botham 'ps -eo fname | grep sublime'",shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
pid = process.pid
print pid

xlp = process.poll()
output, error = process.communicate()
print output, xlp

Is there an output if you run the command in a terminal (independently of python) ?

yes the output doesnt prints anything but the line 3 outputs sublime_ twice because sublime is running twice on machine name botham

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.