Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot read STDIN

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello,
I am trying to send data from html form (POST method) to a perl cgi scipt. I cannnot seem to read the input data from STDIN.
Neither of these work:
$bytes=sysread(IN, $query, $ENV{'CONTENT_LENGTH'});
$bytes2=read(STDIN, $query2, $ENV{'CONTENT_LENGTH'} );

The $bytes value is UNDEF.
$bytes2 shows zero.

$ENV{'CONTENT_LENGTH'} variable shows the length of the data when I print it out.

I do not want to read (param('fieldname') to grab each item, there are many. I would like to get the entire input as one string and parse out speal characters before splitting.

Where is the data?
Is there a module required for READ/SYSREAD?

Thanks
 
correction. Fist read line should be
$bytes=sysread(STDIN, $query, $ENV{'CONTENT_LENGTH'});
not
$bytes=sysread(IN, $query, $ENV{'CONTENT_LENGTH'});

still doesn't work...
Thanks
 
We use one similar to this:

$bytes2=read(STDIN, $query2, $ENV{'CONTENT_LENGTH'} );

and it works fine for us. Are you sure the variables you are posting have values? If you haven't already, put some debugging "print" statements in the POSTing script to make sure the values are what you think they should be.

Also, if you're doing a GET, the "read" method above won't work. For a GET, you'll need to get the $query2 from $ENV{'QUERY_STRING'}.

HTH. Hardy Merrill
Mission Critical Linux, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top