xml & stdin

Discussion in 'Perl' started by Robyn Mylius, Jun 27, 2003.

  1. Robyn Mylius

    Robyn Mylius Guest

    i'm trying to read an xml document sent to a cgi script, but the script just
    seems to be hanging, not using CPU or memory, just no responce.
    i'm just working with simple test scripts at the moment, i want to use the
    xml::Simple module but even that hanging so i'm trying to read it from stdin
    and just write the xml back out.
    what am i doing wrong?
    bellow is the script:

    XML File:
    <config logdir="/var/log/foo/" debugfile="/tmp/foo.debug">
    <server name="sahara" osname="solaris" osversion="2.6">
    <address>10.0.0.101</address>
    <address>10.0.1.101</address>
    </server>
    <server name="gobi" osname="irix" osversion="6.5">
    <address>10.0.0.102</address>
    </server>
    <server name="kalahari" osname="linux" osversion="2.0.34">
    <address>10.0.0.103</address>
    <address>10.0.1.103</address>
    </server>
    </config>

    perl script:
    use XML::Simple;
    #my $config = XMLin("-");

    print "Content-type: text/xml\n\n";
    #use Data::Dumper;
    #print Dumper($config);
    print $ENV{"Request_Method"} . "\n";
    print $ENV{"CONTENT_LENGTH"};

    my $query;
    read( STDIN, $query, $ENV{"CONTENT_LENGTH"} )
    print $query;
     
    Robyn Mylius, Jun 27, 2003
    #1
    1. Advertising

  2. Robyn Mylius

    Sator Arepo Guest

    Robyn Mylius wrote:

    > use XML::Simple;
    > #my $config = XMLin("-");
    >
    > print "Content-type: text/xml\n\n";
    > #use Data::Dumper;
    > #print Dumper($config);
    > print $ENV{"Request_Method"} . "\n";
    > print $ENV{"CONTENT_LENGTH"};
    >
    > my $query;
    > read( STDIN, $query, $ENV{"CONTENT_LENGTH"} )
    > print $query;
    >



    I understand you're entering the XML data on the keyboard.

    The 'read' function call attempts to read characters from STDIN until
    it encounters end-of-file or 'CONTENT_LENGTH' characters have been
    read. It probably hangs because you have entered less than the
    specified number of characters.
     
    Sator Arepo, Jun 27, 2003
    #2
    1. Advertising

  3. Robyn Mylius

    Guest

    "Robyn Mylius" <> wrote in message news:<3efbbc32$0$26634$>...
    > i'm trying to read an xml document sent to a cgi script, but the script just
    > seems to be hanging, not using CPU or memory, just no responce.
    > i'm just working with simple test scripts at the moment, i want to use the
    > xml::Simple module but even that hanging so i'm trying to read it from stdin
    > and just write the xml back out.
    > what am i doing wrong?


    Confusing your problem domains.

    Rolling your own CGI implementation.

    Emiting a CGI response with a content-type header of text/xml but an
    entity body that is not XML.

    Not enabling strctures and warnings.

    Posting to a non-existant newsgroup.
     
    , Jun 27, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Johnathan Doe

    peek at stdin, flush stdin

    Johnathan Doe, May 15, 2004, in forum: C Programming
    Replies:
    5
    Views:
    25,029
    Chatoyer
    May 17, 2013
  2. Charlie Zender

    Reading stdin once confuses second stdin read

    Charlie Zender, Jun 19, 2004, in forum: C Programming
    Replies:
    6
    Views:
    793
    Dan Pop
    Jun 21, 2004
  3. Ben
    Replies:
    2
    Views:
    1,349
    jacob navia
    Aug 29, 2009
  4. Terry Cooper
    Replies:
    7
    Views:
    427
    Janos Sebok
    Jun 9, 2009
  5. Stefano Sabatini
    Replies:
    6
    Views:
    295
    Stefano Sabatini
    Jul 29, 2007
Loading...

Share This Page