Question

I am using Python to automate installation of rpms on a linux box. i m using plink to connect to the linux box. First I need to get the info of already installed certain rpms on the box. for this i am the command

os.system('plink root@server -pw pass rpm -qa|grep string > rpm.txt')

Here the command line interpreters the '|' as a cmd command and throws the error "grep is not recognized as an internal or external command, operable program or batch file"

Also the rpm.txt is created on my machine instead on the linux box.

Anyway i can use the '|' and also makesure that 'rmp.txt' is created in the linux box?

Était-ce utile?

La solution

Try this:

ff=subprocess.Popen("plink root@server -pw pass rpm -qa",shell=False,stdin=subprocess.PIPE) 
ff.communicate("grep string > rpm.txt")

A

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top