문제

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?

도움이 되었습니까?

해결책

Try this:

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

A

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top