scain has asked for the wisdom of the Perl Monks concerning the following question:
I am working on a script that uses LWP to submit a form via POST to a cgi and collect the results. I realize that this topic has been covered before, and many have suggested perldoc lwpcook, which I have read. Nevertheless, I feel I must be missing something, as my script still does not work. At the moment I am getting an error message that looks like this:
I assume the not a SCALAR reference is coming straight from perl, as it is trying to print something that doesn't exist.500 (Internal Server Error) Not a SCALAR reference Client-Date: Mon, 04 Mar 2002 20:42:13 GMT
I am designing this to work on an internal server, but I changed my non working script to run against a similarly configured server at UCSF. Please don't everybody run this script against their server, as I haven't cleared it with them, so if 100 of us hit it all at once, it may go down.
Ok, here the script:
The script get executed like this on the command line:#!/usr/bin/perl -w use strict; use Getopt::Std; use LWP::UserAgent; use HTTP::Request::Common qw(POST); use vars qw($ua); my %opts; getopts('hp:d:i:o:e:v:b:F:', \%opts); my $PROGRAM = $opts{'p'}; my $DB = $opts{'d'}; my $INFILE = $opts{'i'}; my $OUTFILE = $opts{'o'}; my $ESCORE; my $V; my $B; my $F; if (defined $opts{'e'}) { $ESCORE=$opts{'e'}; } else { $ESCORE=0.01; } if (defined $opts{'v'}) { $V=$opts{'v'}; } else { $V=10; } if (defined $opts{'b'}) { $B=$opts{'b'}; } else { $B=10; } if (defined $opts{'F'}) { $F=$opts{'F'}; } else { $F='T'; } #-------------------------------------------------------------- my $seq="GCAGCAGGTCGGTAGGCGGGAAATGGCGACTGGCTGAAGGAGCTGGTTCTGTTGCTGCTGC +GGGGTAAGCGGGAAAGACACCACACA"; $DB = 'baygenomicsdb'; $ua = LWP::UserAgent->new; my $req = HTTP::Request->new(POST => 'http://baygenomics.ucsf.edu/db/c +gi-bin/blast/blast.cgi'); $req->content_type('form-data'); #also tried 'application/x-www-form-u +rlencoded' $req->content( [ PROGRAM => $PROGRAM, DATALIB => $DB, SEQUENCE => $seq, EXPECT => $ESCORE, DESCRIPTIONS => $V, ALIGNMENTS => $B ]); print $ua->request($req)->as_string;
Currently, the -d, -i and -o flags are not used even though they are specified.$ ./test-post.pl -p blastn -d hs_all.fa -i test.in -o test.out
Thanks for your time.
Scott
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: LWP/Post with several arguments
by gav^ (Curate) on Mar 04, 2002 at 21:10 UTC | |
by scain (Curate) on Mar 04, 2002 at 21:22 UTC | |
by theguvnor (Chaplain) on Mar 04, 2002 at 22:02 UTC |