I am using Unix OS and I want to know how to execute a command that is executable from a different software in Python script. I have this software installed into my system called HAL Tools and it has a command called maf2hal with two arguments which are input and output files. The path for the command is saved in my .bash_profile under PATH variable. I call the command from UNIX likewise:
[root ~]$ maf2hal inputfile outputfile
I want to call this command from a Python script. What is the statement or function that I need to use.
1.Use os.popen() to execute command:
import os
os.popen("maf2hal inputfile outputfile")
2.subprocess.call()
from subprocess import call
call("maf2hal inputfile outputfile", shell=True)
You can have a look at os.system
A sample command can be
import os
os.system('maf2hal inputfile outputfile')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With