Re: File upload - probably simple..

2002-12-23 Thread Octavian Rasnita
I'm not sure this regular expression will work for getting all the
file/extensions.

For example, if a file is something like: test.tar.gz
...

Teddy,
Teddy's Center: http://teddy.fcc.ro/
Email: [EMAIL PROTECTED]

- Original Message -
From: "Peter Kappus" <[EMAIL PROTECTED]>
To: "beginners-cgi" <[EMAIL PROTECTED]>
Sent: Monday, December 23, 2002 7:08 PM
Subject: RE: File upload - probably simple..


If you're only uploading jpgs then you could also write this as
my ($name) = $path =~ /\w+\.jpg$/i;

since a regexp match returns an array, you're actually creating an array
with a single element ($name) and mapping it to the return from your match
$path =~ /etc/i;  you're match says "one or more word characters" [A-z0-9_]
followed by ".jpg" at the end of the string ($) and match case insensitively
(using the /i modifier)

In retrospect, Teddy's solution is probably cleaner but hopefully this will
be useful anyway...  this technique is best suited for grabbing various
elements out of a match ie. to grab the filename and extension you'd use:

my ($name, $ext) = $path =~ /(\w+)\.(\w+)$/i;

good luck.
-p


-Original Message-
From: Octavian Rasnita [mailto:[EMAIL PROTECTED]]
Sent: Sunday, December 22, 2002 10:17 AM
To: james lundeen; beginners-cgi
Subject: Re: File upload - probably simple..


Use regular expressions to get only the file name from the path.

You should use something like this:

$path =~ s/^.*[\\\/]//;

Teddy,
Teddy's Center: http://teddy.fcc.ro/
Email: [EMAIL PROTECTED]

- Original Message -
From: "james lundeen" <[EMAIL PROTECTED]>
To: "beginners-cgi" <[EMAIL PROTECTED]>
Sent: Sunday, December 22, 2002 12:56 AM
Subject: File upload - probably simple..


hey, do you have a solution to this?

I need to upload a file, but i just want the file name, not the entire
path.  Currently, it saves the actual file on the server as:

G:\ISIR\ISIR2002gallery\images\isir1.jpg   as the FILENAME!!!

i just want it to save as "isir1.jpg" or whatever the filename is for
the file that the user is uploading...

windows machine path for the file:
G:\ISIR\ISIR2002gallery\images\isir1.jpg

should end up as the following on the linux server:
/home/website1/html/images/isir1.jpg

Anyone with info on this, I'd really appreciate feedback.  Thanks!!!



__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

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




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

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




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




RE: File upload - probably simple..

2002-12-23 Thread Peter Kappus
If you're only uploading jpgs then you could also write this as
my ($name) = $path =~ /\w+\.jpg$/i;

since a regexp match returns an array, you're actually creating an array
with a single element ($name) and mapping it to the return from your match
$path =~ /etc/i;  you're match says "one or more word characters" [A-z0-9_]
followed by ".jpg" at the end of the string ($) and match case insensitively
(using the /i modifier)

In retrospect, Teddy's solution is probably cleaner but hopefully this will
be useful anyway...  this technique is best suited for grabbing various
elements out of a match ie. to grab the filename and extension you'd use:

my ($name, $ext) = $path =~ /(\w+)\.(\w+)$/i;

good luck.
-p


-Original Message-
From: Octavian Rasnita [mailto:[EMAIL PROTECTED]]
Sent: Sunday, December 22, 2002 10:17 AM
To: james lundeen; beginners-cgi
Subject: Re: File upload - probably simple..


Use regular expressions to get only the file name from the path.

You should use something like this:

$path =~ s/^.*[\\\/]//;

Teddy,
Teddy's Center: http://teddy.fcc.ro/
Email: [EMAIL PROTECTED]

- Original Message - 
From: "james lundeen" <[EMAIL PROTECTED]>
To: "beginners-cgi" <[EMAIL PROTECTED]>
Sent: Sunday, December 22, 2002 12:56 AM
Subject: File upload - probably simple..


hey, do you have a solution to this?

I need to upload a file, but i just want the file name, not the entire
path.  Currently, it saves the actual file on the server as:

G:\ISIR\ISIR2002gallery\images\isir1.jpg   as the FILENAME!!!

i just want it to save as "isir1.jpg" or whatever the filename is for
the file that the user is uploading...

windows machine path for the file:
G:\ISIR\ISIR2002gallery\images\isir1.jpg

should end up as the following on the linux server:
/home/website1/html/images/isir1.jpg

Anyone with info on this, I'd really appreciate feedback.  Thanks!!!



__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

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




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

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




RE: broadcast photo on other site not by up load

2002-12-23 Thread Peter Kappus
Season's greets, Eric & fellow Perlites:

Yes, chances are, if you're getting *something* but not an image, you're
either sending the wrong headers to the browser OR you're sending the right
headers and then getting a compilation error...Or both.  On a windows
machine, there's also the possibility that you're not using Binary mode on
your image file handles (but since you're doing it in linux for the time
being, that's one problem we won't have to worry about)

What I usually do when this happens, is right click (from NS6+ or Mozilla)
and do a "view source" on the image itself... in the "source" you'll see the
actual output of your script which will contain the error, if there is one.

Another good test, which I'm sure you've already done, is to makes sure that
when you type
%> perl showphoto.pl
you're script actually compiles, and runs and then spews a bunch of binary
data to your terminal...(after printing Content-type: image/jpg\n\n (or
whatever))
I'd recommend this over redirecting you're output into a file because it
should tell you immediately if you're having compilation errors.

The other thing to do is make sure you're "dying" where appropriate... I
don't remember your original script but make sure you have things like:

open(IMAGE,"myPic.jpg") or die("Couldn't open pic! $!");

(the $! will tell you what actual error occured... this way, if you've got
the wrong path or insufficient priviladges, etc. you'll find out the easy
way...

HTH & good luck!

-Peter




-Original Message-
From: zentara [mailto:[EMAIL PROTECTED]]
Sent: Sunday, December 22, 2002 4:54 AM
To: [EMAIL PROTECTED]
Subject: Re: broadcast photo on other site not by up load


On Sat, 21 Dec 2002 14:07:03 -0700, [EMAIL PROTECTED] (Eric Lin)
wrote:

>   Now I am in linux again,
>I did /usr/bin/perl  /usr/lib/cgi-bin/showphoto.pl > mytestout.jpg
>then at netscape 7 's url type /home/fsshl/mytestout.jpg
>
>it showed
>---
>The image "file:///home/fsshl/mytestout.jpg" cannot be displayed, 
>because it contains errors

Make sure your showphoto.pl script is not outputting an html header.
Can you look at mytestout.jpg with somethong else like "xv".
Look at mytestout.jpg with a hex editor and see what the first few lines
are. Are they a valid jpeg header? Compare it to other known good jpegs
you have.
Your showphoto.pl script should be able to read in a image and then
print it out without corrupting it. Post your showphoto.pl that you are
using.


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

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




IF statments -- short circuit

2002-12-23 Thread David Gilden
PERL 5.6
OSX, Jaguar

Goal, to check against two different passwords.


I think my problem is the "or" is short 'circuited'
is there a way for an IF statement to test for both 
values, so that either  $secret_word or  $secret_word_guest  
will be tested, (I am not looking for AND)

What should happen is that if $secret_word OR $secret_word_guest does not Match $qs 
Then it should print 'Fail'.  It needs to check both!

I have tried this, and still does not do what I want, and I can
understand why.
Thanks.

Dave

PS: someone kill the spanish auto-responder


#!/usr/bin/perl 
my $qs = 'c';
my $secret_word  = 'a';
my $secret_word_guest  = 'b';

if ($qs !~ /$secret_word_guest|$secret_word/) {
print "fail\n"; 
} else { print "go, ok\n";}

 more code...

 # OR  #
 
 
#!/usr/bin/perl 
use CGI qw/:standard/;
use CGI::Carp qw(fatalsToBrowser);
use strict;

my $qs = $ENV{'QUERY_STRING'};

my $secret_word  = 'one';
my $secret_word_guest  = 'two';

if (($qs ne $secret_word_guest) or ($qs ne $secret_word)) {
print "Bad password"; 
exit;
} 

-
# I also tried

if ($qs ne $secret_word_guest or $secret_word)) {
print "Bad password";
exit;
} 




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




DBI.pm install error

2002-12-23 Thread N. Ganesh Babu
I have downloaded the DBI-1.32.tar.gz file and I have decompressed.
I have succefully geneerated the makefile
while running 'make' command I got the following error:

D:\DBI-1.32>make
MAKE Version 5.2  Copyright (c) 1987, 2000 Borland
Error makefile 894: Redefinition of target 'Perl.c'
Fatal makefile 987: No terminator specified for in-line file operator


Can any one tell me what I have to do?

Thanks in advance
Ganesh

--
Your favorite stores, helpful shopping tools and great gift ideas. 
Experience the convenience of buying online with Shop@Netscape! 
http://shopnow.netscape.com/


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



Re: IF statments -- part 2

2002-12-23 Thread zentara
On Mon, 23 Dec 2002 02:10:17 -0600, [EMAIL PROTECTED] (David
Gilden) wrote:

>This is not working either
>
># Goal, to check against two different passwords.
>
>#!/usr/bin/perl 
>my $qs = 'c';
>my $secret_word  = 'a';
>my $secret_word_guest  = 'b';
>
>if ($qs !~ /$secret_word_guest|$secret_word/) {
>print "fail\n"; 
>} else { print "go, ok\n";}
>
>... more code...
>
>
>What should happen is that if $secret_word OR $secret_word_guest does not Match $qs 
>Then it should print 'Fail'.
>
>Please see if you can explain  why this in not working,

It works exactly as you wrote it.

You are telling it "if c does not match a or b" print fail.

Try putting $qs = 'a'   it works fine.
Logic will get you twisted into a pretzel. :-)


Maybe you want
print "fail\n" unless ($qs =~ /$secret_word_guest|$secret_word/);





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




Re: IF statments

2002-12-23 Thread zentara
On Mon, 23 Dec 2002 01:33:58 -0600, [EMAIL PROTECTED] (David
Gilden) wrote:

>I would like to be able to test for either of the two secret words
>but it seems to fail,  what am I missing?

>#!/usr/bin/perl 
>use CGI qw/:standard/;
>use CGI::Carp qw(fatalsToBrowser);
>use strict;
>
>my $qs = $ENV{'QUERY_STRING'};
>
>my $secret_word  = 'one';
>my $secret_word_guest  = 'two';
>
>if (($qs ne $secret_word_guest) or ($qs ne $secret_word)) {
>print "Bad password"; 
>exit;
>} 

Hi, I think your problem is that you are using
my $qs = $ENV{'QUERY_STRING'};  
and you are expecting it to match, it dosn't.

The $ENV{'QUERY_STRING'} actually looks something like
someword&someotherword  
or it may look like
someword=this&someword=that

So 
if (($qs ne $secret_word_guest) or ($qs ne $secret_word)) {
print "Bad password"; 

should always say Bad Password

You might be able to get away with using a regex instead of ne
if (($qs !~ $secret_word_guest) or ($qs !~ $secret_word)) {
print "Bad password"; 

But you are better off using the params given to you by
CGI.pm

if ( param('secret_word) ne $secret_word) or
  ( param('secret_word_guest) ne $secret_word_guest))
{print 'Bad Password'}

You might want to improve that logic, I'm not sure if it does
what you really intend. Like maybe:

if ( param('secret_word) eq $secret_word) or
  ( param('secret_word_guest) eq $secret_word_guest))
{print 'Good Password'}
else {print 'Bad Password'}











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




IF statments -- part 2

2002-12-23 Thread David Gilden
This is not working either

# Goal, to check against two different passwords.

#!/usr/bin/perl 
my $qs = 'c';
my $secret_word  = 'a';
my $secret_word_guest  = 'b';

if ($qs !~ /$secret_word_guest|$secret_word/) {
print "fail\n"; 
} else { print "go, ok\n";}

... more code...


What should happen is that if $secret_word OR $secret_word_guest does not Match $qs 
Then it should print 'Fail'.

Please see if you can explain  why this in not working,

Dave
-
OSX, Jaguar

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