Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

system command problem!

Status
Not open for further replies.

htruong

Programmer
Joined
Jul 11, 2001
Messages
10
Location
VN
I use Perl to write a short program for optimize Netscape iPlanet Server that compiles an application in JavaScript Server side by jasc command. My simple source code as:

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

print "Content-type:text/html\n\n";

$main_dir = "document-root/my_directory";
$web_file = "my_web.web";
$ENV{'PATH'} = '/opt/netscape/suitespot/bin/https/bin';
$ENV{'LD_LIBRARY_PATH'} = '/opt/netscape/suitespot/bin/https/lib';
$st = "jsac -p \"$main_dir\" -f list.txt -o $web_file -r error.txt" ;

print &quot;<HTML><BODY>&quot;;
system($st);
print &quot;Generating success!&quot;);
print &quot;</BODY></HTML>&quot;;
exit;
#############################################################
<i>I saved this file as run.cgi</i>

The jasc running well but allways display these line:
&quot;JavaScript Application Compiler Version 24.13
Copyright (C) Netscape Communications Corporation 1996 1997
All rights reserved.&quot;

When I sumbit my HTML form with action is run.cgi and method POST server always return an error message like &quot;The page can not display...&quot;. Then I view my web server error file and get this line:

[11/Jul/2001:20:06:21] failure ( 2034): for host 203.162.49.43 trying to POST /cgi-bin/admin/run.cgi, cgieng_scan_headers reports: the CGI program /opt/netscape/suitespot/docs/cgi-bin/admin/run.cgi did not produce a valid header (name without value: got line &quot;javascript application compiler version 24.13&quot;)

Please help me for ignoring any return message from SYSTEM command with Perl.

Thanks
Nguyen Truong
 
I don't fully understand what you want to do here - you have a perl cgi script that kicks off a Javascript compile, and it prints out &quot;Generating success!&quot;. Does it seem like the output of the compile is getting mixed in with the STDOUT of your perl cgi script? What do you want to have happen here?

One thing wrong, that should actually cause a syntax error, is the

print &quot;Generating success!&quot;);

The right parenthesis does not belong.
Hardy Merrill
Mission Critical Linux, Inc.
 
Before you print anything to the browser you need to print a content-type header. Try adding this line:
Code:
print &quot;Content-type: text/html\n\n&quot;;
That's a VERY common error in programs run as cgi programs.
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
OOPS, I guess I missed that! :~/ Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Thank for you sugesstions,
To hmerrill,
I was mistake when write this code in posting message. The error message of website is not talking about this systax error!

print &quot;Generating success!&quot;);

You know, when I type <i>jasc</i> from unix command like this:
#jasc -p &quot;/opt&quot; -f list.txt -o $web_file -r error.txt
I always get this message.
<i>JavaScript Application Compiler Version 24.13
Copyright (C) Netscape Communications Corporation 1996 1997
All rights reserved.
#
So, it is a reason I see error message in my Web server when runing source code. I mean, I dont want any notice from result of SYSTEM command in Perl. (like silent running)

OK, I will try compile this code with - option for compiler.





 
Couple of things you might try are:

print &quot;<HTML><BODY>&quot;;
print &quot;<!--&quot;;
system($st);
print &quot;-->&quot;;
print &quot;Generating success!&quot;);

which would enclose the output of the system command in HTML quotes, and won't be shown in the browser (still viewable in the source)

Another way would be to redirect the standard output for that command to a temp file - although, only having just started playing with Perl, not sure how you would do this - anyone?
 
With the system call commented out, the code runs fine (minus the extra paren).
.... I don't see how ......... but, my first suspicion is that the web server process lacks sufficient priviledges to do something in the system call. I realize that does not immediately explain the invalid header. But, since the code runs without the system call.....

I would make sure that the files that the web server is trying to write to already exist and they are writable by the web daemon. Maybe temporarily touch them and chmod 777 just long enough to make this thing work. Then, go back and tighten the permissions as appropriate. Also, that all input files are visiable/readable from the web servers perspective.

also, might try this to make sure the $str string is what you mean it to be...
....
print &quot;<HTML><BODY>&quot;;
print &quot;<p>$st</p>\n&quot;;
# system($st); # temporarily commented out
print &quot;Generating success!&quot;;
print &quot;</BODY></HTML>&quot;;
....


HTH


keep the rudder amid ship and beware the odd typo
 
Try redirecting the output of the command to /dev/null:
Code:
system(&quot;$st >/dev/null&quot;);

Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
I still can not fix this problem. mod off file is OK. Webserver give our an error message on &quot;...name without value: got line...&quot;

Please help me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top