i try to search the Internet but find nothing to solve this problem,
so i decided to write here.
When you run a script from shell it's probably as user 'you'.
When the script runs from a browser, it will be as user 'www' or something similar, with restricted permissions. Your shell user will have more permissions, so you might want to look at file permissions.
Also, you want to check the paths to any files referenced by the script. When runing a script as shell, you can probably access any file on the server, but user 'www' won't be able to.
If you haven't already done this, try something like:
perl -cw script-name.pl
and see if it gives any more info
Good luck!
Dave
Panchroma website development
www.panchroma.ca
> --
> To unsubscribe, e-mail: beginners-cg...@perl.org
> For additional commands, e-mail: beginners...@perl.org
> http://learn.perl.org/
>
>
>
> When you run a script from shell it's probably as user 'you'.
> When the script runs from a browser, it will be as user 'www' or something
> similar, with restricted permissions. Your shell user will have more
> permissions, so you might want to look at file permissions.
>
Of course , it is running under user apache. But i made all chmod and chown
what need, i think.
Also, you want to check the paths to any files referenced by the script.
> When runing a script as shell, you can probably access any file on the
> server, but user 'www' won't be able to.
>
This is okay too, the script only reads config file which has the right
permissions.
I try to exec script from apache user from shell, after making "su -l apache
-s /bin/bash" in console, and it ran perfect... But again - from browser we
got an error.
If you haven't already done this, try something like:
> perl -cw script-name.pl
> and see if it gives any more info
>
This gives me - "syntax OK"
$ua = new LWP::UserAgent;
$query = new CGI;# CGI
print $query->header;
$h1 = new HTTP::Headers;
$req1 = new HTTP::Request ('GET', 'http://www.cpan.org', $h1);
$response=$ua->request($req1);
print Dumper($response);
print $query->end_html;
*
So, when i run this from shell everything is okay and i get cpan.org page,
but from browser it gives Can\'t connect to www.cpan.org:80 (connect:
Permission denied.
You can see this result here http://62.176.11.182:50235/cgi-bin/test1.cgi
(test1.cgi is right the script above).
The problem seems really be in apache or httpd.conf or in CGI , but i can`t
understand where.
*
*
2009/12/19 David Taiaroa <des...@panchroma.ca>
> Does something simple like this work for you? I'm trying to help you narrow
> down where the problem is.
>
> #!/usr/bin/perl
> use CGI ;
> $query = new CGI;# CGI
> print $query->header;
>
> my $url = 'http://www.cpan.org';
> use LWP::Simple;
> my $content = get $url;
> print $content;
>
> print $query->end_html;
>
>
> I have it at http://joiedevivre.nb.ca/cgi-bin/test3.cgi
>
>
> Dave
>
> ok. i modify it a little - i added some strings to print something before
and after print $content;
so now i have
print "before print \$content <br>";
print $content;
print "after print \$content <br> ";
so in shell it is works great, in browser we got -
before print $content
after print $content
... so the $content is empty.
http://62.176.11.182:50235/cgi-bin/test3.cgi
P.S. sorry but this is my home VMware server so it could be down for some
time.
> Hi Alexander,
>
> Is the LWP module in the same directory as the CGI module, and does it have
> permissions 644?
>
Yes, folders CGI and LWP are in /usr/lib/perl5/vendor_perl/5.10.0 and
permissions are 644.
> It drives me crazy, when you got working scripts, you just update linux
version and nothing working... you search the problem everywhere and killing
your brain for days... But somehow in someday you realize that maybe it is
stupid selinux again, and ohhhhhh!!!! it was really it...
I think all developers and system administrator who came from old great
working systems(with lower than 2.6 kernel) to new systems with 2.6 had same
problems, but this is future and now all linux distribution has selinux...
P.S. I just need to read more about it and try to understand how it is
working, instead of disabling it every time :)))). But this lost time of
crushing brain because of selinux again is driving crazy... really.
P.S. thanks for help and tries to solve the problem