I have a script which imbeds a shell command. It works perfectly in the command line, but once I access this script via web browser, it always misfunctions. Here is the code:

################################################################
#!/usr/local/bin/perl

###shell command
$command = `/opt/pkgs/apache/plweb/cgi-bin/fastweb search simple witch 002_txt 500 0 0 witch `;

###print the result
print "Content-type: text\/html\n\n";
print "<!DOCTYPE HTML PUBLIC \"-\/\/W3C\/\/DTD HTML 3.2 Final\/\/EN\">";
print "<html>\n";
print "<head> </head> \n";
print "<body>\n";
print "$command";
print "</body>\n";
print "</html>";

In this script, I call a shell command to evoke an executable file, which is located at the same directory (named "fastweb"). The following strings are the required parameters to be passed to the executable file. It outputs the searching list displaying all the items including the word "witch". The database is located at another directory. Like I said, I can execute the perl script through the command line: ./test.cgi, and it works fine. But when I browse it via web, it always display an error message which is generated by the executable file:
Error 16: Unknown operation.

I also tried the following method:
$command = "/opt/pkgs/apache/plweb/cgi-bin/fastweb search simple witch 002_txt 500 0 0 witch |";

open(FILES,$command);

while($files = <FILES>){
print "$files\n";
push(@test, "$files\n\n");
print "$test[scalar(@test-1]\n";

}

}
close FILES;
print @test;

Here, I am trying to create an array to hold the command results. As you can see, I print before and after pushing new item. The same problem happens. It works in command line, but not for web.

I am really confused, and I've been stuck here for 3 weeks. Does anyone have any idea?

Any help would be appreciated.