My own script:
start python CertDnsUpate.py %*
It will call a python script. It worded well in a cmd command line and renew the dns txt record successfully.(eg. C:"\Program Files\CertifyTheWeb\Scripts\DNS\dnsscript.bat" mydomain _acme-challenge.www.mydomain.com abcdefd)
But it didn’t work in your software.
The log showed:
DNS: (Use Custom Script) :: Warning: Script ran but took too long to exit and was closed.
Not support or something wrong？
Hi, it gets little complicated because when the process runs from the background service it’s running as Local System, the the current user. So you may need to fully qualify the path to your python command (currently it assumes it’s available in the users Path).
I not sure if you need to use
start as that will spawn a new CMD process. you should be able to invoke python normally without it.
Is there any way you be willing to share your python code? I’m having a hard time figuring out how to get the hash txt into the script.
@tdmarchetta I’ll update the scripting docs to add a python example (in answering your question I had to write a script anyway!).
You start with a .bat file which can then forward all the arguments as required to your python script using
%* (or you could pass specific arguments if you needed). Note also the fully qualified path to the python exe as your script will run as local system and the path environment variable settings may be different:
REM This script would be called with the parameters <target domain> <record name> <record value> <zone id (optionally)>
REM this example then calls a custom python script forwarding all the arguments
c:\python27\python.exe create_dns_txt_example.py %*
Then in your python script your args are available in the
sys.argv list. This example passes that list to a function called
main and logs some example stuff (
create_dns_txt_example.py logging to
# TODO: added module for DNS updates (libcloud etc)
# init logging etc
logging.info("Example Python DNS helper.")
# TODO: setup your DNS provider (apache libcloud etc)
# TODO: add/append the txt record
logging.info("args: " + " ".join(sys.argv))
"If this script did anything it would create a TXT record called " + sys.argv
+ " with the value " + sys.argv
+ " you could optionally use the domain ("+sys.argv+") "
+ " or zoneId ("+sys.argv+") in your python script")
if __name__ == "__main__":
When the script runs that app will call the .bat file like:
ExampleDNSCreatePython.bat mydomain.com _acme-challenge.mydomain.com ABCD1234 myoptionalZoneId
Which in turn (based on the above example .bat) will call the python script as :
python create_dns_txt_basic.py.bat mydomain.com _acme-challenge.mydomain.com ABCD1234 myoptionalZoneId