I want a Python program to execute on scheduled or regular intervals using terminal, using mac system but solutions are acceptable for Windows also.
Below is the steps that i want to achieve.
step 1) Open terminal and enter : sudo start --init**
it will prompt to enter user name: usr_name
password '-------------'
step 2) after that run this command
function params1 --params2 “value”
step 3) After 3 to 4 minutes run the same program
, It will ask for killing the previous session and will ask to enter users master password.
or if we can do it in the same terminal press control+C
, it will end the current session and bring the terminal to next line
, then again the command function params1 --params2 “value”
,If we are doing this there will be no need to enter the user name and password as in step 1
The below scripts are not working.In command line it is working out well but it need to be automated and scheduled.The scheduling is the issue.
Any help or suggestions please.
import sys
import subprocess
import os
import openpyn
#sys.path.insert(1, ‘/Users/klr/Downloads/nordvpnipchange/openpyn/openpyn.py’)
#subprocess.check_output([‘ls’,‘-l’])
#subprocess.check_output([‘sudo openpyn --init’])
os.system(“sudo openpyn --init”)
#print(os.system(“sudo openpyn --init”))
#print (subprocess.check_output([“sudo openpyn --init”]))
second one,
import subprocess
import os
subprocess.call(["openpyn DE --area “Berlin"], shell=True)
os.system("openpyn DE --area “Berlin")
Tried it with Automator in Mac as shown below,But don't know how we can schedule it.