# passing variables to python script

**URL:** <https://community.unix.com/t/passing-variables-to-python-script/225191>\
**Category:** Web Development\
**Created:** [December 21, 2008, 2:52am UTC](https://community.unix.com/t/passing-variables-to-python-script/225191 "2008-12-21T02:52:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![darkphaux](https://community.unix.com/letter_avatar/darkphaux/32/5_5575768a8748004e209b776fc1b2916d.png) [@darkphaux](https://community.unix.com/u/darkphaux)\
**Post date:** [December 21, 2008, 2:52am UTC](https://community.unix.com/t/passing-variables-to-python-script/225191/1 "2008-12-21T02:52:14Z")

</div>

Hello again,  
You guys might remember me from the "Apache problems" thread. And because this forum is the only one that actually helped me out after months of problems I was hoping you could help me with something related.

Now if you remember the final code that we made for creating an account on a SQUID proxy server that is what we will be dealing with. If not then here it is:

```nohighlight
#!/usr/bin/python
print "Content-type: text/html\n\n"

import os

def main():
# username = "working123"
# password = "working"
    os.system("htpasswd -b /etc/squid/passwd '%s' '%s'" % (username.replace("'", ""), password.replace("'", "")))
    return 0
if __name__ == ' __main__': main()

```

Now the code works fine, the only problem is that it wors fine with stub values. I need user input, so that a user can input a desired username and a desired password and then those strings would be passed to the python script which would then fill in the data. Now I looked around on google and a few friends and we tried this script:

```nohighlight
 <html>
  <form action="http://192.168.1.4:8000/cgi-bin/test.py" method="POST">

      Name: <input type="text" name="username"><br>
      pass: <input type="text" name="password"><br>
      <input type="submit">

  </form>
  </html>

```

Now it did not work. I found it quite difficult to find info on this agian. Lets see if you guys can go 2 for 2 😃

-Carter
