0

Trying to export multiple path to unix environment before execution followed by multiple script execution on same parent process. Any feedback on be python code while running on the server

import os, subprocess
os.environ['PATHLOC'] = '/home/sys/data/'
os.environ['LOC'] = '/home/tool/dev'
os.environ['ROOT'] = '/servername/data/code'

r1 = subprocess.run(['sh','/home/script/scriptname.sh', 'arg1'],stdout=subprocess.PIPE, stderr=subprocess.stdout)

if r1 == 0:
    r2 = subprocess.run(['sh','/home/script/scriptname2.sh', 'arg1'],stdout=subprocess.PIPE, stderr=subprocess.stdout)
else: 
    print('Process 1 failed : {}'.format(r1))

if r2 <> 0
    print('Process 2 failed : {}'.format(r2))
E88
  • 97
  • 1
  • 9
  • What isn't working for you? – costaparas Jan 30 '21 at 01:46
  • "*Any feedback on be python code while running on the server*" -- is this working code you want to improve? Consider posting to https://codereview.stackexchange.com/. – costaparas Jan 30 '21 at 01:46
  • export path are not being picked during script execution. these part are parameterized path used inside the script during execution – E88 Feb 05 '21 at 03:04
  • Does this answer your question? [set environment variable in python script](https://stackoverflow.com/questions/8365394/set-environment-variable-in-python-script) – costaparas Feb 05 '21 at 05:13
  • Btw its important to describe what the intended behavior of your program is and what isn't working when you post a question. This permits more relevant answers. Your question originally asked for "*feedback on be python code*". – costaparas Feb 05 '21 at 05:14

0 Answers0