Save the output of a command in a string in linux using python
- by user1657901
I am using Fedora 17 xfce and I am programming in Python 2.7.3. Fedora uses a package manager called yum. I have a python script that searches for packages like this:
import os
package = raw_input("Enter package name to search: ")
os.system("yum list " + package)
So I want python to check if in the output of this command exists the words "No matching packages to list". I checked a similar question and I tried some methods [http://stackoverflow.com/questions/2502833/python-store-output-of-subprocess-call-in-a-string][1]
but the string contained only the first line of the output.
Thanks in advance