RE: PATH problem

2005-04-25 Thread TapasranjanMohapatra



-Original Message-
From: Lawrence Statton [mailto:[EMAIL PROTECTED]
Sent: Mon 4/25/2005 8:19 PM
To: TapasranjanMohapatra
Cc: beginners-cgi@perl.org
Subject: Re: PATH problem 
 
> 
> All,
> My script goes like this...
> --
> #!/usr/bin/perl
> print "Content-type: text/html\n\n";
> $cmd = "cat file_one";
> $content = qx!$cmd!;
> print "$content";
> --
> I have a case where file_one is not in the same directory. So I give the abso
> lute path of file_one
> in place of file_one. 
> When run it using perl on command line I get the contents of file printed cor
> rectly.
> 
> But when accessed through browser (cgi-bin), I get nothing printed.
> 
> I thought it might be path problem , but it is not. Because when the file is 
> in same directory,
> it prints the content of the file.
> 
> Can anybody let me know where I am going wrong?
> TIA
> tapas
> 

First: Check permissions.  Can the webserver process (probably running
as a de-privileged user) read that file?

Second:  Is your webserver running in a chroot(2)ed environment, such that
/path/to/file_one is not valid from within its context?

Could you give me some idea how to know if it is chroot(ed). Because the files 
have al the permissions for everyone (777).
Thanks

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
Lawrence Statton - [EMAIL PROTECTED] s/aba/c/g
Computer  software  consists of  only  two  components: ones  and
zeros, in roughly equal proportions.   All that is required is to
sort them into the correct order.







--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: PATH problem

2005-04-25 Thread Lawrence Statton
> 
> All,
> My script goes like this...
> --
> #!/usr/bin/perl
> print "Content-type: text/html\n\n";
> $cmd = "cat file_one";
> $content = qx!$cmd!;
> print "$content";
> --
> I have a case where file_one is not in the same directory. So I give the abso
> lute path of file_one
> in place of file_one. 
> When run it using perl on command line I get the contents of file printed cor
> rectly.
> 
> But when accessed through browser (cgi-bin), I get nothing printed.
> 
> I thought it might be path problem , but it is not. Because when the file is 
> in same directory,
> it prints the content of the file.
> 
> Can anybody let me know where I am going wrong?
> TIA
> tapas
> 

First: Check permissions.  Can the webserver process (probably running
as a de-privileged user) read that file?

Second:  Is your webserver running in a chroot(2)ed environment, such that
/path/to/file_one is not valid from within its context?

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
Lawrence Statton - [EMAIL PROTECTED] s/aba/c/g
Computer  software  consists of  only  two  components: ones  and
zeros, in roughly equal proportions.   All that is required is to
sort them into the correct order.






-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: PATH problem

2005-04-25 Thread Wiggins d'Anconia
TapasranjanMohapatra wrote:
> All,
> My script goes like this...
> --
> #!/usr/bin/perl
> print "Content-type: text/html\n\n";
> $cmd = "cat file_one";
> $content = qx!$cmd!;
> print "$content";
> --

You should not shell out to read a file, Perl is a full programming
language, you should use the builtin functions whenever possible.
Especially when they are common and simple ones. It is faster, safer,
and less bug/error prone.

#!/usr/bin/perl
use strict; # always
use warnings; # pretty much always

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

open my $HANDLE, 'file_one' or die "Can't open file for reading: $!";
while (my $line = <$HANDLE>) {
  print $line;
}
close $HANDLE;

The same thing only faster, much safer, and it will give you diagnostic
output in the error log of the web server to find out why it can't read
a particular file.  See the other poster's comments too.

http://danconia.org

> I have a case where file_one is not in the same directory. So I give the 
> absolute path of file_one
> in place of file_one. 
> When run it using perl on command line I get the contents of file printed 
> correctly.
> 
> But when accessed through browser (cgi-bin), I get nothing printed.
> 
> I thought it might be path problem , but it is not. Because when the file is 
> in same directory,
> it prints the content of the file.
> 
> Can anybody let me know where I am going wrong?
> TIA
> tapas
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: PATH problem

2005-04-25 Thread Sean Davis
Not sure this is the problem, but remember that when you run a CGI 
script from the command line, you are running as yourself.  When you 
run it in the browser, you are running under whatever username and 
group the server is running with (and almost always this is different 
from yourself).  So, you have to be sure that the directory that you 
want to read from can be read by the user under which the browser runs. 
 So, it isn't a PATH problem, but a permissions problem.

Sean
On Apr 25, 2005, at 7:17 AM, TapasranjanMohapatra wrote:
All,
My script goes like this...
--
#!/usr/bin/perl
print "Content-type: text/html\n\n";
$cmd = "cat file_one";
$content = qx!$cmd!;
print "$content";
--
I have a case where file_one is not in the same directory. So I give 
the absolute path of file_one
in place of file_one.
When run it using perl on command line I get the contents of file 
printed correctly.

But when accessed through browser (cgi-bin), I get nothing printed.
I thought it might be path problem , but it is not. Because when the 
file is in same directory,
it prints the content of the file.

Can anybody let me know where I am going wrong?
TIA
tapas
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



PATH problem

2005-04-25 Thread TapasranjanMohapatra

All,
My script goes like this...
--
#!/usr/bin/perl
print "Content-type: text/html\n\n";
$cmd = "cat file_one";
$content = qx!$cmd!;
print "$content";
--
I have a case where file_one is not in the same directory. So I give the 
absolute path of file_one
in place of file_one. 
When run it using perl on command line I get the contents of file printed 
correctly.

But when accessed through browser (cgi-bin), I get nothing printed.

I thought it might be path problem , but it is not. Because when the file is in 
same directory,
it prints the content of the file.

Can anybody let me know where I am going wrong?
TIA
tapas

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: path problem

2005-04-09 Thread Peter Scott
On Fri, 08 Apr 2005 11:59:12 -0400, Shaun Fryer wrote:
>> >use lib "$ENV{'DOCUMENT_ROOT'}/pdftest";
> 
> use lib is done at compile time. the %ENV isn't available til run-time IIRC.

False:

$ perl -le 'print grep /peter/ => @INC'

$ perl -le 'use lib $ENV{HOME}; print grep /peter/ => @INC'
/home/peter
$

-- 
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: path problem

2005-04-08 Thread Shaun Fryer
> >use lib "$ENV{'DOCUMENT_ROOT'}/pdftest";

use lib is done at compile time. the %ENV isn't available til run-time IIRC.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




path problem

2005-04-06 Thread Andrew Kennard
Hi all

Iv'e downloaded a pdf module from CPAN and am trying to use it in my
webspace provided by Demon Internet (www.demon.net) but no matter what I try
it cannot 'find' the module called Reuse.pm which IS in the same directory
as the following script.

!/usr/bin/perl
use lib "$ENV{'DOCUMENT_ROOT'}/pdftest";
use CGI::Carp qw(fatalsToBrowser);
use Reuse;
use PDF::Reuse;
print "Content-type: text/html\n\n";
print "Finished";


It stops on the "use PDF::Reuse;" statement saying it can't find the module
at yet the Use Reuse does not cause an error and the error shows the @inc
path which contains the full path to my working directory.

I've tried Demon's technical support but they offered very little advice

Thanks in advance for your help

Andrew Kennard




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]