Hi,
I would like to know if Python supports codes similar to shell scripts:
count=`ps -ef|grep "pattern"|wc -l`
for count in `echo $count`
do
done
fi
Can I export a variable say var from os.system("var=`ps -ef|grep pattern|wc
-l`")
thanks
__________________________________________________ _______________
Cell phone ?switch? rules are taking effect ? find out more here.
http://special.msn.com/msnbc/consumeradvocate.armx
解决方案count`
do
done
fi
Can I export a variable say var from os.system("var=`ps -ef|grep pattern|wc
-l`")
thanks
__________________________________________________ _______________
Cell phone ?switch? rules are taking effect ? find out more here.
http://special.msn.com/msnbc/consumeradvocate.armx
"Daven Nair" writes:
I would like to know if Python supports codes similar to shell scripts:
count=`ps -ef|grep "pattern"|wc -l`
for count in `echo
count`
do
done
fi
See ''pydoc commands''. You could probably do with
pattern = ""
cmd_status, count = commands.getstatusoutput("ps -ef|grep -c %s" % pattern)
for i in range(count):
# do something count times
Note: you don''t need wc -l after grep, because grep has ''-c'' switch.
Note2: not tested, some typos etc may be present.
--
# Edvard MajakariSoftware Engineer
# PGP PUBLIC KEY available Soli Deo Gloria!