I need to run system command from python
I have python - version - Python 2.4.3
I try the following , in this example ls -ltr | grep Aug
#!/usr/bin/python
import commands
Month = "Aug"
status,output = commands.getstatusoutput(" ls -ltr | grep Month " )
print output
how to insert the Month variable in the command ?
so grep will do that
| grep Aug
I try this also
status,output = commands.getstatusoutput( " ls -ltr | grep {} ".format(Month) )
but I get the following error
Traceback (most recent call last):
File "./stamm.py", line 14, in ?
status,output = commands.getstatusoutput( " ls -ltr | grep {} ".format(Month) )
AttributeError: 'str' object has no attribute 'format'