I have my python script this
var1 = subprocess.Popen("pwd | grep 'home' ");
print var1
But it is giving me error
I have my python script this
var1 = subprocess.Popen("pwd | grep 'home' ");
print var1
But it is giving me error
You need to add shell=True if you want the shell to interpret the pipe correctly:
var1 = subprocess.Popen("pwd | grep 'home' ", shell=True)
(Note that you don't need a semi-colon at the end of the line.) That might not do what you expect, though - that returns a Popen object so then you need to check whether var1.wait() returns 0 or not.
A much easier way, if you just want to find out if the current directory contains 'home', is to do:
if 'home' in os.getcwd():
print "'home' is in the current working directory's path"