0

i´ve a few problems with my python3 scripts.

an php script start an python3 script:

$comando = 'python3 /var/www/html/tmp/' . $usersession . '-newtenent-vcenter1.py';
shell_exec("/usr/bin/nohup ".$comando." >/dev/null 2>&1 &");

the python3 script write a few strings to an new created text file. After all thinks are done, the script sould be start the next python3 script:

os.system('python3 /var/www/html/tmp/' + usersession + '-newtenent-cucm1.py')

BUT, python3 start the script "cucm1.py" and close it imeadlety! The script shoud be open an ssh session with paramiko.

The OS is an Ubuntu 18.x. I´ve added the www-data user to the script directory (so all scripts can be executed by the user www-data):

www-data ALL=(ALL) NOPASSWD: /usr/bin/python3 /var/www/html/

BUT, when we execute the first python3 script from the linux shell (as root) it work´s fine (the second script working fine).

any idea? THANK YOU!

  • Possible duplicate of [What is the best way to call a script from another script?](https://stackoverflow.com/questions/1186789/what-is-the-best-way-to-call-a-script-from-another-script) – rpm192 Sep 20 '19 at 08:08
  • Try importing function (or whatever) in script1 to script2, and then execute it – oo00oo00oo00 Sep 20 '19 at 08:12
  • For calling subprocesses, the "standard way" is via the [subprocess](https://docs.python.org/3.6/library/subprocess.html) module. Honestly though, not sure what you are trying to achieve, but this looks like a very bad way to structure your program – martyn Sep 20 '19 at 08:39
  • thanks for the quick reply! currently i´ve 5 or 6 py scripts. Every script should start the next script (currently with os.system). now i read on the above link, the best way is to import the python3 scripts to one "master" script. an this "master" script execute all other scripts (starting the functions)? – caldwell-27 Sep 20 '19 at 10:13

0 Answers0