Pergunta

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?

Foi útil?

Solução

Try this:

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

A

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top