You are on page 1of 1

Yes it worked !

But actually i want to redirect its output to a file in that case it did not work
as expected
as shown:

[ i need this for ques 2 of control statemennt ]

filename=sys.argv[1]
os.system("ls -l $filename > file_info")
f=open("file_info","r")
str1=f.read()
print(str1)

this code should give details of file that i pass in command line arg
but its giving details of all the files in that directory

i.e
instead of giving output for:
ls -l $filename

its giving output for:


ls -l

please help.

You might also like