I'm writing some shell scripts to check if I can manipulate information on a web server.
I use a bash shell script as a wrapper script to kick off multiple python scripts in sequential order The wrapper script takes the web server's host name and user name and password. and after performing some tasks, hand's it to the python scripts.
I have no problem getting the information passed to the python scripts
host% ./bash_script.sh host user passwd
Inside the wrapper script I do the following:
/usr/dir/python_script.py $1 $2 $3
print "Parameters: "
print "Host: ", sys.argv[1]
print "User: ", sys.argv[2]
print "Passwd: ", sys.argv[3]
The values are printed correctly Now, I try to pass the values to open a connection to the web server: (I successfully opened a connection to the web server using the literal host name)
f_handler = urlopen("https://sys.argv[1]/path/menu.php")
Trying the variable substitution format throws the following error:
HTTP Response Arguments: (gaierror(8, 'nodename nor servname provided, or not known'),)
I tried different variations,
'single_quotes'
"double_quotes"
http://%s/path/file.php % value
for the variable substitution but I always get the same error
I assume that the urlopen function does not convert the substituted variable correctly.
Does anybody now a fix for this? Do I need to convert the host name variable first?
Roland