Code: Select all
import os
import subprocess
import json
if "SAB_NZO_ID" not in os.environ:
print("The environment variable SAB_NZO_ID is not set.")
exit(1)
else
ECHO %SAB_NZO_ID%
Code: Select all
Exit(-1): Cannot run script
Same Script with .bat works perectly.
I see value of SAB_NZO_ID.
Batch
Code: Select all
@echo off
setlocal
if not defined SAB_NZO_ID (
echo Die The environment variable SAB_NZO_ID is not set.
exit /b 1
)
C:\Windows\System32>C:\test\test.py
Code: Select all
The environment variable SAB_NZO_ID is not set.
Why does it work via Batch, but not via Python?
Code: Select all
import os
print("SABnzbd version:", os.environ['SAB_VERSION'])
print("Job location:", os.environ['SAB_COMPLETE_DIR'])
print("Fail msg:", os.environ['SAB_FAIL_MSG'])
# Your code
# Success code
sys.exit(0)
What am I doing wrong?