Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 setting evironment of Linux using python
#1
Hi I am trying to convert a shell script to python. In shell script they are setting the Environment I don't know how to do that using the python here is the sample from the shell script.

# set the test Environment
SAM_HOME=/opt/test
[ -f "~sam/bin/testenv" ] && SAM_HOME=~sam
. $SAM_HOME/bin/testenv
. $SAM_HOME/bin/session
Quote
#2
Hi, I don't know the exact answer to your question, but would it be fine to execute your existing shell script with Python's "os" module?
http://www.pythonforbeginners.com/os/pythons-os-module
Particularly the "os.system()" method:
https://docs.python.org/3/library/os.html#os.system
Quote
#3
hi, I am trying it in python in this way

# set the test Environment
SAM_HOME = "/opt/test"


if os.path.exists("~sam/bin/test"):
SAM_HOME = "~sam"
os.system(". " + SAM_HOME + "/bin/test")
os.system(". " + SAM_HOME + "/bin/session")
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Python in Kali Linux coolcassie 2 173 Dec-02-2019, 12:48 PM
Last Post: coolcassie
  Advice on Setting Up the Python Environment punksnotdead 1 289 May-15-2019, 04:29 PM
Last Post: snippsat
  Setting DCHP in Windows 10 with Python Martin2998 4 617 Dec-07-2018, 10:15 PM
Last Post: Martin2998
  Setting up Python on a Mac - Beginner BrowneyesPage1979 1 496 Aug-30-2018, 10:41 PM
Last Post: snippsat
  Setting up python with visual studio code. Having one issue. xringo 2 1,084 May-21-2018, 12:09 AM
Last Post: snippsat
  Linux, Python 2 to 3 Jtaxel 3 1,516 Aug-06-2017, 12:12 PM
Last Post: Jtaxel
  Python in Linux environment on RPI kendias 17 3,234 Jun-06-2017, 10:58 PM
Last Post: Larz60+

Forum Jump:


Users browsing this thread: 1 Guest(s)