Java with apache from perl script?

Discussion in 'Perl Misc' started by i5513, Oct 29, 2003.

  1. i5513

    i5513 Guest

    Hi, I'm running Apache server with mod_perl active.

    I can run my script from command line and all is fine, but when I run
    my script from navigator, it doesn't run fine because my script is:

    ....
    system "java program_java";
    ....

    How can I do Apache to run java programs?

    Thanks you, I read on google about Tomcat and about Apache Jserver,
    but I don't know where can I start.

    PD: I'm sorry for my poor english.
    i5513, Oct 29, 2003
    #1
    1. Advertising

  2. i5513

    Ben Morrow Guest

    (i5513) wrote:
    > Hi, I'm running Apache server with mod_perl active.
    >
    > I can run my script from command line and all is fine, but when I run
    > my script from navigator, it doesn't run fine because my script is:
    >
    > ...
    > system "java program_java";
    > ...
    >
    > How can I do Apache to run java programs?


    Not like that. Not, in fact, using Perl at all.

    > Thanks you, I read on google about Tomcat and about Apache Jserver,
    > but I don't know where can I start.


    Start in an Apache or Java newsgroup.

    Ben

    --
    It will be seen... that the Erwhonians are a meek and long-suffering people,
    easily led by the nose, and quick to offer up common sense at the shrine of
    logic, when a philosopher arises among them who... convinc[es] them that their
    ....institutions are not based on... morality. [Samuel Butler]
    Ben Morrow, Oct 29, 2003
    #2
    1. Advertising

  3. Ben Morrow <> wrote:
    > (i5513) wrote:
    > > I can run my script from command line and all is fine, but when I run
    > > my script from navigator, it doesn't run fine because my script is:
    > >
    > > ...
    > > system "java program_java";
    > > ...
    > >
    > > How can I do Apache to run java programs?

    >
    > Not like that. Not, in fact, using Perl at all.


    Why not? It just looks like "java" isn't in the CGI process's $PATH...
    Since the OP's script runs from the command line but not the browser,
    I'd recommend the troubleshooting links in the FAQ.

    % perldoc -q 500

    --
    Steve
    Steve Grazzini, Oct 29, 2003
    #3
  4. On 29 Oct 2003 09:26:16 -0800
    (i5513) wrote:

    > Hi, I'm running Apache server with mod_perl active.
    >
    > I can run my script from command line and all is fine, but when I
    > run my script from navigator, it doesn't run fine because my script
    > is:
    >
    > ...
    > system "java program_java";
    > ...
    >
    > How can I do Apache to run java programs?


    If you want to have a Java Applet server, visit:

    http://jakarta.apache.org/tomcat/index.html

    <snip>

    You _could_ use Perl to execute a Java application, but IMHO it would
    be better to use an actual Java server to perform the task.

    HTH

    --
    Jim

    Copyright notice: all code written by the author in this post is
    released under the GPL. http://www.gnu.org/licenses/gpl.txt
    for more information.

    a fortune quote ...
    A fool must now and then be right by chance.
    James Willmore, Oct 29, 2003
    #4
  5. i5513

    Helgi Briem Guest

    On 29 Oct 2003 09:26:16 -0800, (i5513) wrote:

    >Hi, I'm running Apache server with mod_perl active.
    >
    >I can run my script from command line and all is fine, but when I run
    >my script from navigator, it doesn't run fine because my script is:
    >
    >system "java program_java";


    >How can I do Apache to run java programs?
    >

    CGI is run under a special user with restricted rights and
    an empty path variable.

    You should always, yes *always* check the results
    of system operations and return the error ($! for
    internal processes, $? for daughter process).

    Give it the full path to java and the program.

    my $java = '/full/path/to/java';
    my $program_java = '/full/path/to/program_java';
    system ($java $program_java) == 0 or die $?;
    Helgi Briem, Oct 30, 2003
    #5
  6. i5513

    i5513 Guest

    > Give it the full path to java and the program.
    >
    > my $java = '/full/path/to/java';
    > my $program_java = '/full/path/to/program_java';
    > system ($java $program_java) == 0 or die $?;


    Thanks you, my 'particular' problem was the classpath.

    I solved it with:
    $Output = qx/"java -cp /full/path/to/classes
    /full/path/to/program_java"

    on my local apache it seems like perl had C:\winnt\system32 on
    $ENV{PATH}. Java.exe was on winnt\system32 ... I think my perl script
    isn't a CGI program where you says path is empty.

    Thanks you again.
    i5513, Oct 30, 2003
    #6
    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. Wet Basement
    Replies:
    1
    Views:
    2,493
    BobMonk
    Jul 15, 2003
  2. dpackwood
    Replies:
    3
    Views:
    1,757
  3. Replies:
    2
    Views:
    13,708
  4. The Poor
    Replies:
    2
    Views:
    216
    Gregory Toomey
    Sep 27, 2003
  5. pj
    Replies:
    3
    Views:
    270
Loading...

Share This Page