I have written a Python program say:
inp = raw_input("ENTER path ")
f = glob.iglob(os.path.join(path,'*.txt'))
for filename in f:
if filename == 'xnak.txt':
print "this is a valid file"
else:
print 'not recognized'`
Now I want to make it a Unix C shell(csh) command with script-name name.
Please help me out. I don’t have a high level understanding in Unix, basic and simple ideas are welcome.
Simply I just want to make this prog named x.py like the cd command in a csh. You know, wherever you type cd [dirname] the cd function works fine. I need to just make the prog like that.
So that, I won’t need to copying around the program/script from folder to folder for analyzing data of a folder.
like when in a folder I type x 11 (and hit enter) then the program starts executing and stops after executing 11 loops of searching.
If anyone still don’t understand the question properly then please ask for justification rather than downvoting or wrong answering.
If you want your python script to be executable from the shell in unix, you’ll want to do two things:
Add a shebang line that says it should be run using python. This should be the first line of your script, and will probably be something like:
Mark the file as executable, using
chmod. You can do this from the command-line by typing: