I have a Python script called “cal.py” & PHP script called DBfun.php which contains DB calls.
In my DBfun.php script,I have function called
“function get_sby_name($f_haddress,$f_sdesc)”
and I need to pass below #1 & #2 variables to this PHP script and take DB results to Python script and print.
I tried below #3 code part,but cannot pass variables to PHP function from python script.
If there is any way to do this ?
Python Script: cal.py
f_haddress=10.228.86.74 #1
f_sdesc='GR1-SW' #2
f_notify_type=''
#I tried this code part in Pyton file #3
#import subprocess #3
#proc = subprocess.Popen("php /path/to/src/DBfun.php", shell=True, stdout=subprocess.PIPE) #3
#script_response = proc.stdout.read() #3
if(f_notify_type=="PROBLEM"):
f_color="#FF0000"
f_adesc="Status:OK"
else:
f_color="#AEB6BF"
f_adesc="Status:Warning"
print(f_color+''+f_adesc)