Is it possible to get whole commandline include redirection.., etc

Steven W. Orr steveo at syslang.net
Fri Jan 12 18:39:16 EST 2007


On Friday, Jan 12th 2007 at 15:11 -0800, quoth postindex at gmail.com:

=>Can I get whole commandline not only argument list.
=>
=>1. When I command like this
=>    $ a.py > filename
=>2. sys.argv is returns only argument list
=>    ['a.py']
=>
=>Is there a way to find out 'redirection' information.

As a new person to python, I'm going to go out on a limb and declare this 
to not be a python question and to be a Unix question. If you're running 
under Windoze then my answer may not be valid since, as you can see, I 
only recently learned how to spell it.

When any Unix commandline is handed to a shell, all pipes and redirections 
are processed by that shell so that the various IO channels for the 
command are defined to point to the desired files before the command is 
even started. Only after that setup has occured is the desired command 
even started. There are books on the subject and this is not the correct 
forum to explain it all, but the docs to read that will leave you with no 
hint of idiomatic usage are all in section 2: fork, exec, open, close, dup 
and pipe (plus a few others not germain here also).

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net



More information about the Python-list mailing list