I have problem execute this code here
subprocess.check_output(['ps -ef | grep ftp | wc -l'],env=environ,shell=True)
When I execute from terminal
ps -ef | grep ftp | wc -l
I get "1" as output which is fine.
Now, I execute same code from my python files as subprocess.check_output and it gives me 2. That is strange. Any Ideas why is it happening. Here is the complete code:
def countFunction():
environ = dict(os.environ)
return subprocess.check_output(['ps -ef | grep ftp | wc -l'],env=environ,shell=True)
count = countFunction()
print count
EDIT: Just to update , I do not have any ftp connections on.So command line is printing 1 on command which is fine. Thanks Arvind
ftpin it by any chance?ps -ef | grep ftpand finding where the extra process is coming from.ps -ef | grep ftpmight, depending on timing, find not onlyftp, but alsogrep ftp...