Please help with a lot of frustration at below dialogs:
-) why does "subprocess.check_output(["ls","-rt","."])" produce no output, though at least is accepted?
-) why is "subprocess.check_output(["ls -rt","."]) " not accepted at all?
-) most of all: how can I, in python, get the name of the most recent file that matches some regex? My idea was to feed something like "ls -rt $REGEX | head -1" to python, but python seems to strongly dislike such an approach..?
karel@suske:~/home_shared/develop/airnav_db$ python --version
Python 2.7.6
karel@suske:~/home_shared/develop/airnav_db$ python -c 'import subprocess ; subprocess.check_output(["ls -rt","."])'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.7/subprocess.py", line 566, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
karel@suske:~/home_shared/develop/airnav_db$ python -c 'import subprocess ; subprocess.check_output(["ls","-rt","."])'
karel@suske:~/home_shared/develop/airnav_db$ ls -l
total 52
drwxrwxrwx 2 karel users 4096 Oct 11 2009 auxdata
...