I have a python app that run some bash script commands. I want to convert those command to python Can anyone help me how do to that?
import subprocess
def connection():
subprocess.run(["pkexec", '/bin/bash', '-c', country], check=True)
country = '''
#!/usr/bin/env bash
usa=$(wget -qO- http://ipecho.net/plain | xargs echo)
geoiplookup $usa
if geoiplookup $usa | grep us ; then
echo "It's usa"
else
echo "It isn't usa"
exit 1
fi
CodePudding user response:
You need to just rewrite the code in bash, or do something like this:
./python-script.py
CodePudding user response:
Then you should pack your code inside a .bash file and execute it using OS sub-process execution.