-1

Could you please suggest on how to execute Linux command through Python to Start & Stop SAP Host Agent.

Path: .(/usr/sap/hostctrl/exe)

To stop hostagent: ./saphostexec -stop
To start hostagent: ./saphostexec -start

PrakashG
  • 1,642
  • 5
  • 20
  • 30
  • 1
    Possible duplicate of [Running Bash commands in Python](https://stackoverflow.com/questions/4256107/running-bash-commands-in-python) – tripleee Feb 07 '19 at 06:05

1 Answers1

-1

we can use the os module of python to do it.

import os

os.chdir('/usr/sap/hostctrl/exe')

# for starting hostagent
os.system("./saphostexec -start pf=host_profile")

# to know the status of hostagent
os.system("./saphostexec -status pf=host_profile")

# for stopping hostagent
os.system("./saphostexec -start pf=host_profile")
Eric Aya
  • 69,473
  • 35
  • 181
  • 253