what's wrong calling a Perl/CGI script in Perl/CGI script under Tomcat server?

Discussion in 'Perl Misc' started by kath, Apr 9, 2007.

  1. kath

    kath Guest

    Hi all,

    I have small doubt, the following code works fine in Apache server.
    But not completely in Tomcat. Why??
    ------------------------
    #!C:\Perl\bin\perl.exe

    # hello.pl

    use CGI;
    $cgi = new CGI;
    print $cgi->header;
    printf "Hello world";
    system("perl Hi.pl");
    ------------------------
    #!C:\Perl\bin\perl.exe

    # hi.pl

    print "Hi";
    ------------------------

    When I tried in Tomcat, the script prints only
    Hello world

    Why?
    What's wrong?


    kath.
    kath, Apr 9, 2007
    #1
    1. Advertising

  2. Re: what's wrong calling a Perl/CGI script in Perl/CGI script underTomcat server?

    kath wrote:
    > I have small doubt, the following code works fine in Apache server.
    > But not completely in Tomcat. Why??


    <snip>

    Why don't you ask Perl

    > system("perl Hi.pl");


    system("perl Hi.pl") == 0 or die $!;

    and check the server's error log?

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Apr 9, 2007
    #2
    1. Advertising

  3. kath

    J. Gleixner Guest

    Re: what's wrong calling a Perl/CGI script in Perl/CGI script underTomcat server?

    kath wrote:
    > Hi all,
    >
    > I have small doubt, the following code works fine in Apache server.
    > But not completely in Tomcat. Why??
    > ------------------------
    > #!C:\Perl\bin\perl.exe
    >
    > # hello.pl
    >
    > use CGI;
    > $cgi = new CGI;
    > print $cgi->header;
    > printf "Hello world";
    > system("perl Hi.pl");
    > ------------------------
    > #!C:\Perl\bin\perl.exe
    >
    > # hi.pl
    >
    > print "Hi";
    > ------------------------
    >
    > When I tried in Tomcat, the script prints only
    > Hello world
    >
    > Why?
    > What's wrong?


    perldoc -q "Why can't I get the output of a command with system"
    J. Gleixner, Apr 9, 2007
    #3
  4. Re: what's wrong calling a Perl/CGI script in Perl/CGI script underTomcat server?

    J. Gleixner wrote:
    > kath wrote:
    >
    >> Hi all,
    >>
    >> I have small doubt, the following code works fine in Apache server.
    >> But not completely in Tomcat. Why??
    >> ------------------------
    >> #!C:\Perl\bin\perl.exe
    >>
    >> # hello.pl
    >>
    >> use CGI;
    >> $cgi = new CGI;
    >> print $cgi->header;
    >> printf "Hello world";
    >> system("perl Hi.pl");
    >> ------------------------
    >> #!C:\Perl\bin\perl.exe
    >>
    >> # hi.pl
    >>
    >> print "Hi";
    >> ------------------------
    >>
    >> When I tried in Tomcat, the script prints only
    >> Hello world
    >>
    >> Why?
    >> What's wrong?

    >
    >
    > perldoc -q "Why can't I get the output of a command with system"


    That's not applicable here, is it?

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Apr 9, 2007
    #4
  5. kath

    J. Gleixner Guest

    Re: what's wrong calling a Perl/CGI script in Perl/CGI script underTomcat server?

    Gunnar Hjalmarsson wrote:
    > J. Gleixner wrote:
    >> kath wrote:
    >>
    >>> Hi all,
    >>>
    >>> I have small doubt, the following code works fine in Apache server.
    >>> But not completely in Tomcat. Why??
    >>> ------------------------
    >>> #!C:\Perl\bin\perl.exe
    >>>
    >>> # hello.pl
    >>>
    >>> use CGI;
    >>> $cgi = new CGI;
    >>> print $cgi->header;
    >>> printf "Hello world";
    >>> system("perl Hi.pl");
    >>> ------------------------
    >>> #!C:\Perl\bin\perl.exe
    >>>
    >>> # hi.pl
    >>>
    >>> print "Hi";
    >>> ------------------------
    >>>
    >>> When I tried in Tomcat, the script prints only
    >>> Hello world
    >>>
    >>> Why?
    >>> What's wrong?

    >>
    >>
    >> perldoc -q "Why can't I get the output of a command with system"

    >
    > That's not applicable here, is it?


    Nope.. nevermind.. I missed that 'Hi' was just going to STDOUT, not to a
    variable.
    J. Gleixner, Apr 9, 2007
    #5
    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. Guest
    Replies:
    0
    Views:
    3,673
    Guest
    Jan 18, 2004
  2. hocho888
    Replies:
    1
    Views:
    604
  3. Edward V. Berard
    Replies:
    4
    Views:
    894
    John B. Matthews
    Apr 4, 2006
  4. pj
    Replies:
    3
    Views:
    271
  5. Leo
    Replies:
    3
    Views:
    234
    Brian McCauley
    Mar 23, 2006
Loading...

Share This Page