0

Created a hta application which when button is clicked it opens a linux server and executed pre defined commands.

The below list with 2 single word commands logs into linux server and runs the cmd. it is working fine. But for the 3rd cmd df -kh | grep -i pmon, due to some issue i am unable to run those commmands.

scrip=["pwd","date","df -kh | grep -i pmon"];
    for i in scrip:
        proc=Popen("plink.exe -pw xxx un@zz.com pbrun ohsdba -u orinstance "+i,shell=True,stdout=PIPE,universal_newlines=True )
            output=proc.stdout.read();
        print(output)
    time.sleep(2)

I get the following error. 'grep' is not recognized as an internal or external command, operable program or batch file.

Rithesh Bhat
  • 127
  • 1
  • 12

1 Answers1

0

Since you've set shell=True, the pipe sign is probably interpreted locally, so it tries to run grep on your local Windows machine, instead of on the linux server.

You should consider quoting the command you want to run remotely. There are some suggestions on how to quote in Python here: Python module to shellquote/unshellquote?

Ove
  • 770
  • 4
  • 9