A python.py script lies in a directory that is above the directories date and data. Each data directory contains two ON and OFF directories as ~/dir_pyhton.py/dir_dates/dir_data/dir_ON, dir_OFF How can the python script be pointed to run in dir_ON and dir_OFF with a bash or tcsh command? - or another way?
Asked
Active
Viewed 120 times
0
-
1Why not pass the directory as an argument to the python script: `python the_script.py dir_data/dir_ON`? and `python the_script.py dir_data/dir_OFF` and read it as `sys.argv[1]` in combination with `os.chdir(path)` – Matt Apr 09 '14 at 15:07
-
1If I understand correctly, your question has already been answered [here](http://stackoverflow.com/questions/431684/how-do-i-cd-in-python) – drez90 Apr 09 '14 at 15:07
1 Answers
0
You can use the find
command to locate the ON and OFF directories, then pass them to the python script, like so:
cd ~/dir_pyhton.py/
find dir_dates/dir_data -type d \( -name "dir_ON" -or -name "dir_OFF" \) | xargs python python.py

nofinator
- 2,906
- 21
- 25