When executed from an html page, or by the web server, the script is being executed as a different user than when you run the script from the command line. In this case the web server user is running the script. Because of this you may need to provide the full path to "java". I don't know where java exists on the system but your command may need to look something like this:
system("/usr/bin/java pan");
----
I'm running Apache web server and, yes, you can make "system" calls inside a CGI script. Even PHP provides the shell_exec() function. That does not mean that you don't have to be careful doing so. With careless programming, you can open yourself up to big problems. Server configurations vary, of course, and some may restrict cgi completely.
I tested a small perl script to verify that the results of a shell command can be captured and displayed on a web page. This is the script:
#!/usr/bin/perl
@result = `echo "Hello from the command line!"`;
print "Content-type: text/html\r\n\r\n";
print "
\n";
for(@result) {
chomp($_);
print "- $_
\n";
}
print "
\n";
This script uses the backtick (`) operator instead of the system() function to execute the call because it makes capturing the results easier. @result is used in array context in case multiple lines are returned. This script outputs the following:
Content-type: text/html
- Hello from the command line!
I called the script using Safari web browser and the page displayed as expected.
I hope this helps!