Hi, I am trying to send key:value pair to perl script via sub-process module . I just tried with simple example it works fine. How can I pass key:value pair to perl script .....?
Ans also how can send multiple input fields value to perls script> Below is my code view.py ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- from django.http import HttpResponseRedirect, HttpResponse from django.shortcuts import get_object_or_404, render_to_response from django.template import RequestContext from subprocess import Popen, PIPE, sys import subprocess def ex(request): myName = 'Pervez' if 'firstname' in request.POST: myName = (request.POST['firstname']) p = Popen(['/home/pervez/Desktop/simplepage/simplepage/templates/ex.pl', myName],stdin=PIPE, stdout=PIPE) p.stdin.close() result = p.stdout.read() return render_to_response('ex.html', {'name': result},context_instance=RequestContext(request)) ex.pl ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- #!/usr/bin/perl $|=1; # Flush immediately. print "Content-Type: text/plain\n\n"; read(STDIN,$form, $ENV{'CONTENT_LENGTH'}); foreach $pair (split('&', $form)) { if ($pair =~ /(.*)=(.*)/) { # found key=value; ($key,$value) = ($1,$2); # get key, value. $value =~ s/\+/ /g; # substitute spaces for + signs. $value =~ s/%(..)/pack('c',hex($1))/eg; $inputs{$key} = $value; # Create Associative Array. } } foreach $item (keys(%inputs)) { print "$item - $inputs{$item}\n"; } ex.html ----------------------------------------------------------------------------------------------------------- {{ name }} <FORM METHOD="POST" ACTION="" NAME="SIGNUPFORM"> {% csrf_token %} <fieldset> <legend>Signup Form</legend> <table> <tr><td>First Name</td><td><INPUT SIZE=20 NAME="firstname"> </td></tr> <tr><td>Last Name</td><td><INPUT SIZE=20 NAME="lastname"></td></tr> <tr><td>User Name</td><td><INPUT SIZE=20 NAME="username"></td></tr> <tr><td>Password</td><td><INPUT SIZE=20 NAME="password"></td></tr> <tr><td>Verify Password</td><td><INPUT SIZE=20 NAME="vpass"></td></tr> <tr><td>Your E-mail</td><td><INPUT SIZE=20 NAME="email_id"></td></tr> <tr><td align="right"> </td> <td><input type="submit" value="Submit"> <input type="Reset" value="Clear Form"> </td> </tr> </table> </fieldset> </form> Please Help me Pervez -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/t5r_rscbvOEJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.