Script runs fine from shell, but browser doesn't receive variables 
Author Message
 Script runs fine from shell, but browser doesn't receive variables

I have a script that simply reads a directory, stores the file names
in an array, uses those filenames to open a string of text files and
print the output to the browser that calls the script.

From the shell it works great, but from the browser I get not out put.
To test it, I disabled the part where it reads the files themselves
and tried to get it to just print the file names. This too works from
shell but not from the browser.

I even put in a test print statement that prints to the browser fine
just before the expected list of file names, but no go.

Here is my script:

#!/usr/bin/perl
require "cgi-lib.pl";
&ReadParse (*input);
$pathtogroup="/path to a group/";
$fullpathtogroup="fullpath to a group/";

($sec,$min,$hour)=localtime(time);
$ip = $ENV{'REMOTE_ADDR'};

print "Content-type: text/html", "\n\n";
print "<HTML>", "\n";
print "<HEAD><TITLE>Test.pl</TITLE></HEAD>", "\n";
print "<BODY>", "\n";

&getdir;

print "All files \n"; # this is my test line. It prints fine.

print "</BODY></HTML>", "\n";

sub getdir{


closedir jeff;

$i=2; # this routine opens the files and prints the whole contents
# to the shell, but wont print in browser



close (blah);




$i++;

Quote:
}

return

Quote:
}


browser should pick it up.

Any ideas?



Fri, 22 Oct 1999 03:00:00 GMT  
 Script runs fine from shell, but browser doesn't receive variables

In comp.lang.perl.misc,

[cgi script]

Quote:
>From the shell it works great, but from the browser I get not out put.

Did you read the FAQs? What uid does the httpd run under? Did you check
whether the executable file has the right permissions to be executed by
that uid?

<sigh>

HTH,

Alain

--
Perl information: <URL:http://www.perl.com/perl/>
        Perl FAQ: <URL:http://www.perl.com/perl/faq/>
    Perl archive: <URL:http://www.perl.com/CPAN/>

Quote:
>>>>>>>>>>>>> NB: comp.lang.perl.misc is NOT a CGI group <<<<<<<<<<<<<<



Fri, 22 Oct 1999 03:00:00 GMT  
 Script runs fine from shell, but browser doesn't receive variables

On Mon, 05 May 1997 18:48:37 GMT, Jeffrey Morgan wrote in

++ I have a script that simply reads a directory, stores the file names
++ in an array, uses those filenames to open a string of text files and
++ print the output to the browser that calls the script.
++
++ From the shell it works great, but from the browser I get not out put.
++ To test it, I disabled the part where it reads the files themselves
++ and tried to get it to just print the file names. This too works from
++ shell but not from the browser.
++
++ I even put in a test print statement that prints to the browser fine
++ just before the expected list of file names, but no go.
++
++ Here is my script:

Did you check what the error file says? I catch 99.5% of the bugs that way.

++ #!/usr/bin/perl

You don't have -w. You don't have -T.

++ require "cgi-lib.pl";

You don't have use CGI; You don't have use strict.

++ &ReadParse (*input);
++ $pathtogroup="/path to a group/";
++ $fullpathtogroup="fullpath to a group/";
++
++
++ ($sec,$min,$hour)=localtime(time);
++ $ip = $ENV{'REMOTE_ADDR'};
++
++
++ print "Content-type: text/html", "\n\n";
++ print "<HTML>", "\n";
++ print "<HEAD><TITLE>Test.pl</TITLE></HEAD>", "\n";
++ print "<BODY>", "\n";
++
++ &getdir;
++
++ print "All files \n"; # this is my test line. It prints fine.

++ print "</BODY></HTML>", "\n";
++
++ sub getdir{
++
++ opendir (jeff, "$fullpathtogroup$group\/");

You don't check the return value.


++ closedir jeff;

You don't check the return value.


Not at all? Not even the newline?

++ $i=2; # this routine opens the files and prints the whole contents
++ # to the shell, but wont print in browser
++

++

You don't check the return value.


++ close (blah);

You don't check the return value.

++


++

++ $i++;
++ }
++ return
++
++ }
++
++

++ browser should pick it up.
++
++ Any ideas?

Many. See above.

Abigail



Fri, 22 Oct 1999 03:00:00 GMT  
 Script runs fine from shell, but browser doesn't receive variables

: I have a script that simply reads a directory, stores the file names
: in an array, uses those filenames to open a string of text files and
: print the output to the browser that calls the script.

: From the shell it works great, but from the browser I get not out put.

The very first Frequently Asked Question in the Perl FAQ, part 9,
which deals with "Networking" (even though it is not a Perl question
at all, but a CGI question best asked in one of the CGI newsgroups
such as comp.infosystems.www.authoring.cgi):

----------------------
=head2 My CGI script runs from the command line but not the browser.  Can you help me fix it?

Sure, but you probably can't afford our contracting rates :-)

Seriously, if you can demonstrate that you've read the following FAQs
and that your problem isn't something simple that can be easily
answered, you'll probably receive a courteous and useful reply to your
question if you post it on comp.infosystems.www.authoring.cgi (if it's
something to do with HTTP, HTML, or the CGI protocols).  Questions that
appear to be Perl questions but are really CGI ones that are posted to
comp.lang.perl.misc may not be so well received.

The useful FAQs are:

    http://www.perl.com/perl/faq/idiots-guide.html
    http://www3.pair.com/webthing/docs/cgi/faqs/cgifaq.shtml
    http://www.perl.com/perl/faq/perl-cgi-faq.html
    http://www-genome.wi.mit.edu/WWW/faqs/www-security-faq.html
    http://www.boutell.com/faq/
----------------------

[snip]

: Any ideas?

Try reading the FAQ?  ;-)

--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming



Fri, 22 Oct 1999 03:00:00 GMT  
 Script runs fine from shell, but browser doesn't receive variables

I will never understand the need to publically humiliate someone,
while wasting precious bandwidth, to say something like:

Read the FAQ.

Well, I read the Idiots etc before I posted. I suppose next time I
will say that I read it, but that will probably result in someone
saying read it again.

The sad thing is that only one person here actually said something
useful without being snide. Another at least gave me some good
information without being too insulting. I even received two emails
that told me the same things the worst of you said. At least they
weren't so childish as to post them publically.

Just a little hint, if you are trying to help someone by suggesting
they read something informative, please use email. It uses less
bandwidth and shows that you really mean to try and help. Otherwise,
try and call home to Mother and learn some manners. All public
{*filter*} achieves is bitterness. You think I am useless for not
knowing the right group to post in or the right FAQ to read. I think
you are an insensative and egotistical in your superiority. My fault
was ignorance which can be corrected over time. Yours, however...well
that doesn't need to be said.



Sat, 23 Oct 1999 03:00:00 GMT  
 Script runs fine from shell, but browser doesn't receive variables

::SIGH::

Hmm? I believe your module namespace is incorrect in the above example...
Perhaps you meant:

CGI::SIGH

--
Clay Irving                                        See the happy moron,

http://www.panix.com/~clay                         I wish I were a moron,
                                                   My God! Perhaps I am!



Sat, 23 Oct 1999 03:00:00 GMT  
 Script runs fine from shell, but browser doesn't receive variables

: ::SIGH::

: Hmm? I believe your module namespace is incorrect in the above example...
: Perhaps you meant:

: CGI::SIGH

I thought it was a JAPH kinda thing:

So I Go Hacking?

--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming



Sun, 24 Oct 1999 03:00:00 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Help: Running Perl script from Shell script, passing variables

2. Child shell script output doesn't appear

3. Couldn't get perl scripts to run on web browsers in Windows95

4. system() won't run shell script correctly

5. Perl script doesn't run

6. perl-script doesn't run

7. GD.pm problem: script runs fine on command line but not across webserver

8. runs okay in shell, not in browser

9. Getting parent process's environment variable to change when running a perl script

10. Scheme Shell: Shell Scripting for the 90's

11. Incomplete output from crontab email: running shell scripts from a perl script

12. Running Perl script w/i Unix Shell Script

 

 
Powered by phpBB® Forum Software