Ask a Question related to PERL Beginners, Design and Development.
-
Owen #1
Different results Command Line/CGI
I have this script stolen and modified from somewhere
#!/usr/bin/perl -w
use strict;
use File::Find;
print "Content-type: text/html\n\n";
my $u=shift;
my $sizes = 0;
# replace this with your absolute path
my $path = "/home/$u/";
find (sub {$sizes += -s ;}, $path);
print "$sizes\n";
I am logged onto my machine as user owen and am root. From the command line I execute
perl /var/www/cgi-bin/ff1.cgi owen with the result
--------------------------
Content-type: text/html
(warnings snipped)
504137000
---------------------------
with rcook as the user in /home the result is 988865
Now when I do 'links [url]http://localhost/cgi-bin/ff1.cgi?owen[/url]'
the result is 350200607 (vs 504137000 ???) and
for user rcook the result is 0 (vs 988865)
du gives me yet another set of answers as does other File::Find type programs I have found, but that is not the problem at the moment.
Why do I get 0 for rcook when I run it through the browser?
I suspect the difference is something to do with permissions of the cgi script when run as a cgi script but do not know.
Any advice/clues would be most welcome
TIA
--
Owen
Owen Guest
-
How do I get to the command line?
I just loaded UBUNTU on a machine, and I need to load an NVIDIA driver. The instructions tell me to type "sh NVIDIA...", but I cannot find a way... -
command-line
hey guys, i'm trying to grep some data from a log file and getting the following error. Any ideas??? $ perl -e 'grep \"Eliminating movie\"... -
RUN/execute a Command-Line command from an ASP page
Hi, I need to RUN/execute a Command-Line command from an ASP page. This is the command: sse45.exe -i k:\o\2.wmv -o k:\o\2.shh -w 128 -df 0 -m 2... -
RUN/execute a Command-Line command from an ASP page.
Hi, I need to RUN/execute a Command-Line command from an ASP page. This is the command: sse45.exe -i k:\o\2.wmv -o k:\o\2.shh -w 128 -df 0 -m 2... -
command line in OS 8.5
Hello, I need your help. I have a G3 Desktop at work with OS 8.5 (german version). There seems to be some weird keystroke combination that... -
Ramprasad A Padmanabhan #2
Re: Different results Command Line/CGI
Owen wrote:
That is percisely why.> I have this script stolen and modified from somewhere
>
> #!/usr/bin/perl -w
> use strict;
> use File::Find;
> print "Content-type: text/html\n\n";
>
> my $u=shift;
> my $sizes = 0;
> # replace this with your absolute path
> my $path = "/home/$u/";
>
> find (sub {$sizes += -s ;}, $path);
> print "$sizes\n";
>
>
> I am logged onto my machine as user owen and am root.
From the command line I execute>
> perl /var/www/cgi-bin/ff1.cgi owen with the result
>
> --------------------------
> Content-type: text/html
>
> (warnings snipped)
>
> 504137000
> ---------------------------
>
> with rcook as the user in /home the result is 988865
>
> Now when I do 'links [url]http://localhost/cgi-bin/ff1.cgi?owen[/url]'
>
> the result is 350200607 (vs 504137000 ???) and
> for user rcook the result is 0 (vs 988865)
>
> du gives me yet another set of answers as does other File::Find type programs I have found, but that is not the problem at the moment.
>
> Why do I get 0 for rcook when I run it through the browser?
> I suspect the difference is something to do with permissions of the cgi script when run as a cgi script but do not know.
>
>
>
> Any advice/clues would be most welcome
>
>
> TIA
>
Your web server may not be running as user root and therefore it may not
have permissions to go to all directories.
Hence you would get a zero
Ram
Ramprasad A Padmanabhan Guest
-
Dan Muey #3
RE: Different results Command Line/CGI
Stealling is bad! :)> I have this script stolen and modified from somewhere
Permissions Permissions Permissions:>
> #!/usr/bin/perl -w
> use strict;
> use File::Find;
> print "Content-type: text/html\n\n";
>
> my $u=shift;
> my $sizes = 0;
> # replace this with your absolute path
> my $path = "/home/$u/";
>
> find (sub {$sizes += -s ;}, $path);
> print "$sizes\n";
>
>
> I am logged onto my machine as user owen and am root. From
> the command line I execute
>
> perl /var/www/cgi-bin/ff1.cgi owen with the result
>
> --------------------------
> Content-type: text/html
>
> (warnings snipped)
>
> 504137000
> ---------------------------
>
> with rcook as the user in /home the result is 988865
>
> Now when I do 'links [url]http://localhost/cgi-bin/ff1.cgi?owen[/url]'
>
> the result is 350200607 (vs 504137000 ???) and
> for user rcook the result is 0 (vs 988865)
>
The user the webserver is runnign at obvioulsy doesn't have
permissions to "see" all the files that the user you where
logged in as did. And it is not allowed to see the rcook directory at
all aparently.
HTH
Dmuey
Dan Muey Guest
-
Vishal Vasan #4
How to call perl with in-line contents?
Hi All,
I have a file with the following contents (temp.txt).
A1110
G1115
B1110
C1111
D1111
E1113
F1115
and so on. I have to read the contents from this file and create 2
seperate files. The 1st file contains the lines ending with 0 and 1
while the 2nd file contains the lines ending with 3 and 5. I can do this
easily by creating a seperate perl script. But I have a constraint. I
should not write a seperate file to do this processing.
I am calling the perl from a shell script. Is there any way of calling
the Perl program "in-line" with all the required parameters? "In-line"
means no seperate file containing the script.
Is it worth doing this? Is there a better way of doing it?
Regards,
Vishal Vasan.
Vishal Vasan Guest
-
James Edward Gray II #5
Re: How to call perl with in-line contents?
On Feb 13, 2004, at 6:24 AM, Vishal Vasan wrote:
Is there a reason not to just use a Perl script, instead of a shell> Hi All,
>
> I have a file with the following contents (temp.txt).
> A1110
> G1115
> B1110
> C1111
> D1111
> E1113
> F1115
> and so on. I have to read the contents from this file and create 2
> seperate files. The 1st file contains the lines ending with 0 and 1
> while the 2nd file contains the lines ending with 3 and 5. I can do
> this easily by creating a seperate perl script. But I have a
> constraint. I should not write a seperate file to do this processing.
>
> I am calling the perl from a shell script. Is there any way of calling
> the Perl program "in-line" with all the required parameters? "In-line"
> means no seperate file containing the script.
>
> Is it worth doing this? Is there a better way of doing it?
script? We can definitely do all the work in one Perl script.
#!/usr/bin/perl
use strict;
use warnings;
die "Usage: perl script_name INPUT_FILE_NAME\n" unless @ARGV;
my $file = shift;
open INPUT, '<', $file or die "File error: $!";
open SMALLOUT, '>', "01$file" or die "File error: $!";
open BIGOUT, '>', "2+$file" or die "File error: $!";
while (<INPUT>) {
chomp;
if (/[01]\s*$/) { print SMALLOUT "$_\n"; }
else { print BIGOUT "$_\n"; }
}
close INPUT;
close SMALLOUT;
close BIGOUT;
__END__
Hope that helps.
James
James Edward Gray II Guest
-
Benjamin Walkenhorst #6
Re: How to call perl with in-line contents?
On Fri, 13 Feb 2004 17:54:54 +0530
Vishal Vasan <vishal.v@net-kraft.com> wrote:
You can do all the stuff in one perl-script. You can just put it on top> Hi All,
>
> I have a file with the following contents (temp.txt).
> A1110
> G1115
> B1110
> C1111
> D1111
> E1113
> F1115
> and so on. I have to read the contents from this file and create 2
> seperate files. The 1st file contains the lines ending with 0 and 1
> while the 2nd file contains the lines ending with 3 and 5. I can do
> this easily by creating a seperate perl script. But I have a
> constraint. I should not write a seperate file to do this processing.
>
> I am calling the perl from a shell script. Is there any way of calling
>
> the Perl program "in-line" with all the required parameters? "In-line"
>
> means no seperate file containing the script.
>
> Is it worth doing this? Is there a better way of doing it?
of the data:
#!/path/to/perl -w
# Your perl-code goes here
DATA
A1110
G1115
B1110
C1111
D1111
E1113
F1115
....
--------------------------
Then you can treat the file's content after the line
DATA
as a file by using the filehandle <DATA> to read from it.
Kind regards,
Benjamin
Benjamin Walkenhorst Guest
-
John McKown #7
Re: How to call perl with in-line contents?
On Fri, 13 Feb 2004, Vishal Vasan wrote:
This may be hearsy here on the Perl list, but is Perl the best choice in> Hi All,
>
> I have a file with the following contents (temp.txt).
> A1110
> G1115
> B1110
> C1111
> D1111
> E1113
> F1115
> and so on. I have to read the contents from this file and create 2
> seperate files. The 1st file contains the lines ending with 0 and 1
> while the 2nd file contains the lines ending with 3 and 5. I can do this
> easily by creating a seperate perl script. But I have a constraint. I
> should not write a seperate file to do this processing.
>
> I am calling the perl from a shell script. Is there any way of calling
> the Perl program "in-line" with all the required parameters? "In-line"
> means no seperate file containing the script.
>
> Is it worth doing this? Is there a better way of doing it?
>
> Regards,
> Vishal Vasan.
this case? If I had to imbed this in a shell script, I'd use grep twice.
grep '[01]$' input.file >output.file.01
grep '[35]$' input.file >output.file.35
--
Maranatha!
John McKown
John McKown Guest
-
Tim #8
Re: How to call perl with in-line contents?
The "deep" opinions are interspersed with your original message. An in-line
(pardon the "win32-ish-ness" quote escaping) could take the form:
perl -ne "BEGIN{open S, '>smf';open L, '>lgf'} chomp;if (/[01]\s*$/){print
S \"$_\n\";}else{print L \"$_\n\";}" f1.txt
where your data is in f1.txt, your "0" or "1" ending lines go into "smf",
and the others go into "lgf"
At 05:54 PM 2/13/04 +0530, you wrote:Only your boss and the deadline knows for sure>Hi All,
>
>I have a file with the following contents (temp.txt).
>A1110
>G1115
>B1110
>C1111
>D1111
>E1113
>F1115
>and so on. I have to read the contents from this file and create 2
>seperate files. The 1st file contains the lines ending with 0 and 1 while
>the 2nd file contains the lines ending with 3 and 5. I can do this easily
>by creating a seperate perl script. But I have a constraint. I should not
>write a seperate file to do this processing.
>
>I am calling the perl from a shell script. Is there any way of calling the
>Perl program "in-line" with all the required parameters? "In-line" means
>no seperate file containing the script.
>
>Is it worth doing this?
As always, yes. That's the cool part about this language, but don't take>Is there a better way of doing it?
more than 3 minutes... ;-)
>Regards,
>Vishal Vasan.
>
>--
>To unsubscribe, e-mail: [email]beginners-unsubscribe@perl.org[/email]
>For additional commands, e-mail: [email]beginners-help@perl.org[/email]
><http://learn.perl.org/> <http://learn.perl.org/first-response>
>Tim Guest



Reply With Quote

