runs okay in shell, not in browser 
Author Message
 runs okay in shell, not in browser

Hello!

I've been puzzling over this piece of code for some time now. It runs
perfectly when I execute it by typing in its name (or when I type "perl
userlog.cgi", but the script refuses to run if I call it via a web
browser-- it displays only a small part of the middle of the expected
output:

Here is the script:
----------------------
#!/bin/perl
# userlog.cgi

print "Content-type: text/html", "\n\n";
        print "<HTML>", "\n\n";
        print "<HEAD>", "\n\n";
        print "<TITLE>", "Users logged in ","</TITLE>","\n\n";
        print "</HEAD>","\n\n";
        print "<BODY>\n";

%ucnt = ();
for (`who`) {
        s/\s.*\n//;
        $ucnt{$_}++;

Quote:
}





<BR> ";

Quote:
}

        print "\n", "</BODY>","\n\n";
        print "</HTML>","\n\n";
---------------
end of script

And this is what it displays:

Users logged in: someuser someuser
                           |- this has the correct email address link

Any idea why it doesnt run thru a browser?
(file permissions are 755)

Sent via Deja.com http://www.*-*-*.com/
Share what you know. Learn what you don't.



Fri, 04 Jan 2002 03:00:00 GMT  
 runs okay in shell, not in browser

: Subject: runs okay in shell, not in browser

   Perl FAQ, part 9:

      "My CGI script runs from the command line but not the browser.
       (500 Server Error)"

: I've been puzzling over this piece of code for some time now. It runs
: perfectly when I execute it by typing in its name (or when I type "perl
: userlog.cgi", but the script refuses to run if I call it via a web
: browser-- it displays only a small part of the middle of the expected
: output:

   So there must be something different in the environment then.

   Like:

      a different current directory

      a different path

      a different set of environment variables

: for (`who`) {

   Try giving the complete path to who, in case it is not in
   the WWW server's path.

--
    Tad McClellan                          SGML Consulting

    Fort Worth, Texas



Fri, 04 Jan 2002 03:00:00 GMT  
 runs okay in shell, not in browser

Quote:

> Here is the script:
> ----------------------
> #!/bin/perl
> # userlog.cgi

> print "Content-type: text/html", "\n\n";
>         print "<HTML>", "\n\n";
>         print "<HEAD>", "\n\n";
>         print "<TITLE>", "Users logged in ","</TITLE>","\n\n";
>         print "</HEAD>","\n\n";
>         print "<BODY>\n";

> %ucnt = ();
> for (`who`) {
>         s/\s.*\n//;
>         $ucnt{$_}++;
> }





> <BR> ";

> }
>         print "\n", "</BODY>","\n\n";
>         print "</HTML>","\n\n";
> ---------------
> Any idea why it doesnt run thru a browser?
> (file permissions are 755)

Make sure you have perl in /bin. Also check permission of user who run
httpd. Your code work fine in my server.
Hope this help.
Nobi


Sat, 05 Jan 2002 03:00:00 GMT  
 runs okay in shell, not in browser

Quote:

> Hello!

> I've been puzzling over this piece of code for some time now. It runs
> perfectly when I execute it by typing in its name (or when I type "perl
> userlog.cgi", but the script refuses to run if I call it via a web
> browser-- it displays only a small part of the middle of the expected
> output:

[cut...]

If it only displays a small part of the middle of the expected output
(you mean it does this in the browser right??) then the script doesent
refuse to run.
If you take a look at the HTML the script produces, everything should be
there.
(view source from the menu)

BestRegards
Martin Q



Sat, 05 Jan 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Script runs fine from shell, but browser doesn't receive variables

2. output in shell, but not in browser?

3. Scripts work from shell but not browser

4. UnixODBC - DBD::ODBC not connecting when run from browser

5. browser call opens text does not run perl script

6. looking for simple browser - cgi compatible -not lynx -not netscape

7. Reading unix shell environment thru browser?

8. NT displaying and not not running .pl scripts

9. If run from browser to this

10. PGPERL problems when running from browser

11. Running script locally in browser

12. cannot run *.pl on browser

 

 
Powered by phpBB® Forum Software