My code lists the files and directory under a folder and if we want to read
the file it uses the function  cat.

But the function cat(get_file) is not working , any suggetions?

Here is my code:


#!/usr/bin/python

import os
import sys
import commands
#import cat

def listdir(s):
   try:
 file  = os.listdir(s)
for files in file:
path = os.path.join(s, files)
 print path
#cmd = 'ls -l '+ path
#g= commands.getstatusoutput(cmd)
 #print g[1]
   except OSError:
print "No such file or directory"


def main():
listdir(sys.argv[1])


if __name__ == "__main__":
 main()

def cat(get_file):
f = open(get_file, "rU")
 text = f.read()
print text,
get_file = raw_input("Which file would you like to browse ?")

-- 
Anirudh Srinivasan | MTS QA | Nutanix.Inc | 408-569-0323
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to