Different responses from different systems

Discussion in 'Perl' started by Tigerhillside, Feb 22, 2004.

  1. I have an odd problem with my perl script. The code follows, but
    here is the problem. I have a simple script, s.pl, that sends
    back the time as a web page and write the calling parameters to a
    file. (This will, of course, do more eventually, I just want to
    make sure that some other script properly calls this script.)
    When I run s.pl from the command line on my windows system it
    works just fine. The html returned is correct, the correct stuff
    goes into the file. I then put it on my Apache server. When I run
    it from the command line (perl s.pl abc=def) on that server I get
    the following results in the file:

    Sorry: Sat Feb 21 20:20:22 2004
    page:
    c_regex:
    root_selected:
    do: fileman
    txt_input: perl s.pl abc=def
    c_content:
    work_path: html/cgi-bin
    working_dir: /usr/home/web/users/a0017412/html/cgi-bin
    c_case:
    cmd_do: cmd_command
    scope:


    More oddly, when I call this from a browser I get the right stuff
    in the file, but I get a 500 Internal Server Error returned. So
    there is something odd going on, but I can't figure out what.

    (BTW, I know there are easier ways to do the following, but I am
    new to perl and have sort of grown and shrunk this script during
    debugging.)

    [begin code]

    #!/usr/bin/perl -w

    use CGI;

    $query = new CGI;

    use Time::localtime;

    local *MYFILE;
    my $myfilename;
    $myfilename = "./a.txt";
    open ( MYFILE, ">>$myfilename" ) || die("can't open datafile:
    $!") ;

    my $now;
    $now = ctime();
    print (MYFILE "\r\nSorry: $now\r\n" );

    my $params;

    $outQuery = new CGI;
    print $query->start_html("Credit Card Problem Page");

    print $outQuery->header;
    print "Sorry: $now";
    print $outQuery->end_html;


    my %parmHash;

    %parmHash = $query->Vars;


    my($key, $value);
    while ( ($key, $value) = each(%parmHash) )
    {
    if ( $key ne "session_id" ) {

    print (MYFILE $key );
    print (MYFILE ": " );

    print (MYFILE $value );
    print (MYFILE "\r\n" );
    }
    }

    [end code]
     
    Tigerhillside, Feb 22, 2004
    #1
    1. Advertising

  2. BTW, I have gone through the troubleshooting steps and those
    don't help. My script "works", that is, it compiles with strict,
    gives no warnings, does what it is supposed to do, but still
    gives the error.

    In comp.lang.perl, Tigerhillside
    <>, I read and responded

    >I have an odd problem with my perl script. The code follows, but
    >here is the problem. I have a simple script, s.pl, that sends
    >back the time as a web page and write the calling parameters to a
    >file. (This will, of course, do more eventually, I just want to
    >make sure that some other script properly calls this script.)
    >When I run s.pl from the command line on my windows system it
    >works just fine. The html returned is correct, the correct stuff
    >goes into the file. I then put it on my Apache server. When I run
    >it from the command line (perl s.pl abc=def) on that server I get
    >the following results in the file:
    >
    >Sorry: Sat Feb 21 20:20:22 2004
    >page:
    >c_regex:
    >root_selected:
    >do: fileman
    >txt_input: perl s.pl abc=def
    >c_content:
    >work_path: html/cgi-bin
    >working_dir: /usr/home/web/users/a0017412/html/cgi-bin
    >c_case:
    >cmd_do: cmd_command
    >scope:
    >
    >
    >More oddly, when I call this from a browser I get the right stuff
    >in the file, but I get a 500 Internal Server Error returned. So
    >there is something odd going on, but I can't figure out what.
    >
    >(BTW, I know there are easier ways to do the following, but I am
    >new to perl and have sort of grown and shrunk this script during
    >debugging.)
    >
    >[begin code]
    >
    >#!/usr/bin/perl -w
    >
    >use CGI;
    >
    >$query = new CGI;
    >
    >use Time::localtime;
    >
    >local *MYFILE;
    >my $myfilename;
    >$myfilename = "./a.txt";
    >open ( MYFILE, ">>$myfilename" ) || die("can't open datafile:
    >$!") ;
    >
    >my $now;
    >$now = ctime();
    >print (MYFILE "\r\nSorry: $now\r\n" );
    >
    >my $params;
    >
    >$outQuery = new CGI;
    >print $query->start_html("Credit Card Problem Page");
    >
    >print $outQuery->header;
    >print "Sorry: $now";
    >print $outQuery->end_html;
    >
    >
    >my %parmHash;
    >
    >%parmHash = $query->Vars;
    >
    >
    >my($key, $value);
    >while ( ($key, $value) = each(%parmHash) )
    >{
    > if ( $key ne "session_id" ) {
    >
    > print (MYFILE $key );
    > print (MYFILE ": " );
    >
    > print (MYFILE $value );
    > print (MYFILE "\r\n" );
    > }
    >}
    >
    >[end code]
    >
     
    Tigerhillside, Feb 22, 2004
    #2
    1. Advertising

  3. Tigerhillside wrote:
    > when I call this from a browser I get the right stuff in the file,
    > but I get a 500 Internal Server Error returned.


    See reply in the existing group alt.perl.

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, Feb 22, 2004
    #3
  4. Tigerhillside

    Joe Smith Guest

    Tigerhillside wrote:

    > #!/usr/bin/perl -w
    > use CGI;


    use CGI::Carp 'fatalsToBrowser'; # Avoid "500 Server Error"

    > $myfilename = "./a.txt";


    What directory is this file going to be created in?
    Different web servers do different things.
    You should use an absolute pathname, or do an
    explicit chdir("/usr/home/web/users/a0017412/html").

    -Joe
     
    Joe Smith, Feb 23, 2004
    #4
    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. PJ

    Watch Http Request/Responses

    PJ, Aug 16, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    2,400
    Ken Cox [Microsoft MVP]
    Aug 16, 2003
  2. Steven Livingstone

    http pipline, ihttpmodule and filtering responses

    Steven Livingstone, Oct 16, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    477
  3. Luiz Vianna
    Replies:
    2
    Views:
    430
    Luiz Vianna
    Nov 13, 2003
  4. Kevin C
    Replies:
    3
    Views:
    1,593
    Kevin C
    Oct 20, 2004
  5. Mike
    Replies:
    2
    Views:
    668
Loading...

Share This Page