Ho uno script python che si trova sotto questa directory:Python: il sottoprocesso con differenti directory di lavoro
work/project/test/a.py
All'interno a.py
, io uso subprocess.POPEN
per avviare il processo da un'altra directory,
work/to_launch/file1.pl, file2.py, file3.py, ...
Python Codice:
subprocess.POPEN("usr/bin/perl ../to_launch/file1.pl")
e sotto lavoro/progetto /, digito il seguito ing
[[email protected] project]python test/a.py,
errore "file2.py, 'Nessun file o directory'"
Come posso aggiungere work/to_launch/
, in modo che questi file dipendenti file2.py
si possono trovare?
si può provare argomento usin CWD in Popen: http://stackoverflow.com/questions/1685157/python-popen-working-directory-argument – Ayrat
In Python usare 'os importazione 'then' os.chdir ('/ tmp/yourdirectory') 'Questo imposterà la directory corrente per il tuo script python. –