Passing Command Line argument to Python script to be able to open a connection to a web server
<p>I'm writing some shell scripts to check if I can manipulate information on a web server.</p>

<p>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.</p>

<p>I have no problem getting the information passed to the python scripts</p>

<pre><code>host% ./bash_script.sh host user passwd
</code></pre>

<p>Inside the wrapper script I do the following:</p>

<pre><code>/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]
</code></pre>

<p>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)</p>

<pre><code>f_handler = urlopen("https://sys.argv[1]/path/menu.php")
</code></pre>

<p>Trying the variable substitution format throws the following error:</p>

<pre><code>HTTP Response Arguments:  (gaierror(8, 'nodename nor servname provided, or not known'),)
</code></pre>

<p>I tried different variations, </p>

<pre><code>'single_quotes' 
"double_quotes"
http://%s/path/file.php % value  
</code></pre>

<p>for the variable substitution but I always get the same error</p>

<p>I assume that the urlopen function does not convert the substituted variable correctly.</p>

<p>Does anybody now a fix for this? Do I need to convert the host name variable first?</p>

<p>Roland</p>
