Re: upload file
Check out your form tag in the html page. does all the params set properly it should be something like this. form name=myform action=getfile.pl onsubmit=return check_form(); enctype=multipart/form-data method=POST The last param enctype is a must for file input type. which is genrally not their for normal forms let me know if you get it. regards Rajeev - Original Message - From: Konstantin [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, September 09, 2001 7:35 PM Subject: upload file Hi. I'm trying to upload file with the next code: #!/usr/bin/perl use DBI; use CGI qw/:standard/; no strict; use constant MAX_FILE_SIZE = 1_048_576; use constant BUFFER_SIZE = 16_384; my $buffer = ; my $cgi=new CGI; my $filename=$cgi-param('picture') || die (No file name received.); my $file=$cgi-upload('picture') || die (No file received.); $filename =~ s/^.*[\\|\/]//g; $filename=~s/://g; open(OUTPUT,d:/pics/.$filename) || die (Can not open output file); binmode OUTPUT; binmode INPUT; my ($buffer,$bytesread); while($bytesread=read($file,$buffer,1024) ){ print OUTFILE $buffer; } close INPUT; close OUTFILE; I get error message No file received. so the execution of line my $file=$cgi-upload('picture') fails. Can anybody please help? Thanks in advance. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: upload file
Thank you very much. Now I get the file. But how do I get the name of the file now? Is it the matter of choice : the file or its name?:) - Original Message - From: Rajeev Rumale [EMAIL PROTECTED] To: Konstantin [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, September 20, 2001 9:07 AM Subject: Re: upload file Check out your form tag in the html page. does all the params set properly it should be something like this. form name=myform action=getfile.pl onsubmit=return check_form(); enctype=multipart/form-data method=POST The last param enctype is a must for file input type. which is genrally not their for normal forms let me know if you get it. regards Rajeev - Original Message - From: Konstantin [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, September 09, 2001 7:35 PM Subject: upload file Hi. I'm trying to upload file with the next code: #!/usr/bin/perl use DBI; use CGI qw/:standard/; no strict; use constant MAX_FILE_SIZE = 1_048_576; use constant BUFFER_SIZE = 16_384; my $buffer = ; my $cgi=new CGI; my $filename=$cgi-param('picture') || die (No file name received.); my $file=$cgi-upload('picture') || die (No file received.); $filename =~ s/^.*[\\|\/]//g; $filename=~s/://g; open(OUTPUT,d:/pics/.$filename) || die (Can not open output file); binmode OUTPUT; binmode INPUT; my ($buffer,$bytesread); while($bytesread=read($file,$buffer,1024) ){ print OUTFILE $buffer; } close INPUT; close OUTFILE; I get error message No file received. so the execution of line my $file=$cgi-upload('picture') fails. Can anybody please help? Thanks in advance. -- 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]
A Framework for Building An WML/HTML Application Using Perl???
Hey all, I'm trying to modify an existing script that searches a test file for what one could qualify as normal phonebook style entries; name, phone #, email addy, etc. We've got an internal presentation coming up in two weeks, and my boss would like to WAP-ify this directory for it. That almost certainly means moving the app to produce an XML doc of some kind. Ideally, I would like to use XSLT to convert the raw XML doc into WML and HTML; to seperate data from presentation of course. The Perl script would handle the actual search mechanism, any logic required to detect different browsers, and the handling of the XSL transformations. Can anybody provide a few pointers on the best approach to take with this? More specifically, any recommended modules that could be used to facilitate this? How can I detect different WAP browsers??? Thanks! DTS -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: A Framework for Building An WML/HTML Application Using Perl???
At 09:30 AM 9/10/2001 -0500, David Simcik wrote: Hey all, I'm trying to modify an existing script that searches a test file for what one could qualify as normal phonebook style entries; name, phone #, email addy, etc. We've got an internal presentation coming up in two weeks, and my boss would like to WAP-ify this directory for it. That almost certainly means moving the app to produce an XML doc of some kind. Ideally, I would like to use XSLT to convert the raw XML doc into WML and HTML; to seperate data from presentation of course. The Perl script would handle the actual search mechanism, any logic required to detect different browsers, and the handling of the XSL transformations. The most comprehensive XSL Transform API for Perl is Matt Sergeant's AxKit. http://www.axkit.org/. It works with mod_perl and is quite heavily optimized. Can anybody provide a few pointers on the best approach to take with this? More specifically, any recommended modules that could be used to facilitate this? How can I detect different WAP browsers??? You can detect different WAP browsers with an Agent string, but really there are some guidelines to programming WAP in a fairly cross-browser way. I've programmed for about 12 different WAP phones and found many of them to be quite similar with the original Nokia 7110 and Motorola PDA phone being the biggest offenders and pain in my neck programming. Caveat: my experiences may not be the same as you may find because I wrote my apps for use in a GSM market phones in Asia. But if you are in the USA, your WAP phones may have different quirks than the entire rest of the world. As a shameless plug, I would direct you to the book Applied Perl edited by Peter Williams where I've written a chapter on programming WAP applications using Perl based on my experiences writing WAP and SMS enabled Web-applications in that market. Anyway, since all you really want is a demo, I would just download one of the WAP emulators and just simply code for that emulator and your life will be much easier than coding some weird XSLT transform. I am of the opinion that WML is really so completely different and changes your forms so drastically and what you would want to display and bring back as data, that a simple XSLT transform is not enough -- you really require logic changes to the application. People talk all the time about separation of UI from application code, but to some degree, the UI medium does have a big effect on the workflow of the application. For example, in an HTML app, you can often get away with long parameters passed back and forth but in WML where you might have a single HTML form split into many WML forms, you have to more readily maintain the state of the previous forms in your WML application which requires more session logic. These things can't really be emulated in a simple transform. Good Luck, Gunther -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
weird activity...
i have a cgi script to enter user data, etc. i am also loading a couple images. when the cgi comes up on my web browser, ( i am running rh7.1, apache 1.3.19 PHP/4.04p11 mod_perl/1.24_01 and using opera ) the form is there fine and works. my images don't show up. there is no error in the error.log, no entry for the image in the access log, and when i open the source, i do see the IMG SRC tags there? how can that be? since i am not using mod_perl do i need to disable that? matt -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: STDIN loop help
Would something like this help? $i=1 while(my $line=STDIN) { chomp $line; push @integer,$line; # push a scalar onto the array print Enter another integer, please: ; last if ++$i=10; } - Original Message - From: David Draley [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, September 10, 2001 2:48 PM Subject: STDIN loop help Hello - I am trying to put an @array in a loop that stores STDIN. Every time I run my program I can't get out of the loop. Is there a command that pushes the program out of the loop or do I need to use $ print Please enter 10 integer values.\n; $i = 1; while ($i = 10) { @integer = STDIN; chomp @integer; print Enter another integer, please: ; $i++; } print @integer; thank you David _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- 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]
I'm stuck
Hi, I've a little problem. The next cgiscript doesn't work. (The mailfile will be created but i get a server error at my browser) But if i comment the 3 lines between comment out, then this script will work. (i see the generated HTML-page at my browser) Does anybody see what the problem is ? Thanks in advance Peter #!/usr/local/bin/perl -w use CGI; $query = new CGI; $teamleader = me.myself\@my_island.see; $mailfile = /home/myself/mymail..$$; # Comment out these lines and this perl script will work open (mailfile,.$mailfile); print mailfile Originator : .$query-param('ORIG').\n; close (mailfile); # End comment out #unlink ($mailfile); print $query-header('text/html'); print $query-start_html('Input CR','me.myself\@my_island.see'); print $query-h1('Your request is sended to the teamleader :'.$teamleader); print $query-end_html(); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: I'm stuck
Hi, You need to establish your headers before you print anything. Lisa Wolfisch Nyman [EMAIL PROTECTED] IT Warrior Princess Life is too short to wear ugly underwear. Get the facts at http://quickfacts.census.gov/ On Mon, 10 Sep 2001, Peter Bosmans wrote: But if i comment the 3 lines between comment out, then this script will work. (i see the generated HTML-page at my browser) Does anybody see what the problem is ? Thanks in advance #!/usr/local/bin/perl -w use CGI; $query = new CGI; $teamleader = me.myself\@my_island.see; $mailfile = /home/myself/mymail..$$; # Comment out these lines and this perl script will work open (mailfile,.$mailfile); print mailfile Originator : .$query-param('ORIG').\n; close (mailfile); # End comment out #unlink ($mailfile); Move this up before you print anything. print $query-header('text/html'); print $query-start_html('Input CR','me.myself\@my_island.see'); print $query-h1('Your request is sended to the teamleader :'.$teamleader); print $query-end_html(); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: weird activity...
i have a cgi script to enter user data, etc. i am also loading a couple images. when the cgi comes up on my web browser, ( i am running rh7.1, apache 1.3.19 PHP/4.04p11 mod_perl/1.24_01 and using opera ) the form is there fine and works. my images don't show up. there is no error in the error.log, no entry for the image in the access log, and when i open the source, i do see the IMG SRC tags there? how can that be? since i am not using mod_perl do i need to disable that? If you manually try to load the images, what happens? Say, for example, your script is here: http://www.domain.com/cgi-bin/script.pl And your images are referred this way: src=../images/bob.jpg In which case, try to load this file: http://www.domain.com/cgi-bin/../images/bob.jpg What happens? Most of the time, non-executable files located in a cgi-bin directory can NOT be accessed. If you're using relative links (like above - with .. or just plain /), then try switching to absolute links (http://www.domain.com/images/bob.jpg;) and see what happens. -- Morbus Iff ( i am your scary godmother ) http://www.disobey.com/ http://www.gamegrene.com/ please me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554 icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: I'm stuck
Hi, Oops - sorry - didn't see you were printing to the mailfile - Nevermind that one. You may not have permissions to open the mailfile. Try printing $! and see what you get as an error. It's always best to do error trapping on open() calls. If you print $! to standard output, you will need the headers first. -lisa On Mon, 10 Sep 2001, Lisa Nyman wrote too quickly: You need to establish your headers before you print anything. But if i comment the 3 lines between comment out, then this script will work. (i see the generated HTML-page at my browser) Does anybody see what the problem is ? Thanks in advance #!/usr/local/bin/perl -w use CGI; $query = new CGI; $teamleader = me.myself\@my_island.see; $mailfile = /home/myself/mymail..$$; # Comment out these lines and this perl script will work open (mailfile,.$mailfile); print mailfile Originator : .$query-param('ORIG').\n; close (mailfile); # End comment out #unlink ($mailfile); Move this up before you print anything. print $query-header('text/html'); print $query-start_html('Input CR','me.myself\@my_island.see'); print $query-h1('Your request is sended to the teamleader :'.$teamleader); print $query-end_html(); -- 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]
Renaming a File
Is there a function that will let you rename a file from say file.txt to file.bck? Thanks. - Scott
Re: Renaming a File
Yes, and surprisingly enough, it's called rename. :) I've had bad luck using rename, I've had to copy the file to the new name and deep six the old, check out File::Copy, I think it ironically, has a function called copy(), or even cp(), my memory eludes me. -- justin simoni! http://skazat.com ___ We NEVER clean the toilet, Neil! That's what being a student is all about! No way, Harpic! No way, Dot! All that Blue Loo scene is for squares. One thing's for sure, Neil. When Cliff Richard wrote Wired for Sound, no way was he sitting on a clean lavatory! He was living on the limit, just like me. Where the only place to put bleach is in your hair! -Rick, from the Young Ones -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Renaming a File
Yes, and surprisingly enough, it's called rename. :) I've had bad luck using rename, I've had to copy the file to the new name and deep six the old, check out File::Copy, I think it ironically, has a function called copy(), or even cp(), my memory eludes me. There's also one called in that same module called move/mv, which is functionally the same as renaming a file, depending on the system you are on. -- Brett http://www.chapelperilous.net/ This PORCUPINE knows his ZIPCODE ... And he has VISA!! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Renaming a File
Scott == Scott Heckel [EMAIL PROTECTED] writes: Scott Is there a function that will let you rename a file from say Scott file.txt to file.bck? Thanks. Yes, and surprisingly enough, it's called rename. :) -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Renaming a File
Well, what was your $! when the rename failed? If it was cross-device link, then you attempted something that you really can't do. I don't think it was anything like that, as with many :) real world problems, it's a bit more complicated than that. The file in question on my failure was an email subscription list, so an email had to be searched for in one file, a new version of this file had to be created that had the file's content sans found email and then this list had to be written back into where it used to be, so it was something like (reduced to Algorythmic fluff for clarity): -- open OLDFILE, $oldfile; open TEMPFILE, $tempfile; while TEMPFILE next if $email eq '$_'; print TEMPFILE $_; end while close OLDFILE; close TEMPFILE; delete($oldfile); # ahem rename($tempfile, $oldfile); -- a BIG problem with this was that the live file with the subscription list was hit several times a second for large lists which also makes the file kinda hefty. so, yeah, this was just asking for trouble. My solution was to first make my Highlander, 'There shall be only one' temp file lock and with that protection, make my temp file with the changes, close both the temp and live file, open the live file for overwritting, and the temp file for reading, and then just delete the temp file. I'm pretty happy with the performance, as the site that was really having problems.. hasn't since we changed this routine and their list is somewhere around 70,000 - 100,00, this site is http://redjellyfish.com the software is (*cough* shameless plug) http://mojo.skazat.com -- justin simoni personal musings ~ http://skazat.com _ force a change On 9/10/01 8:04 PM, Randal L. Schwartz [EMAIL PROTECTED] wrote: Justin == Justin Simoni [EMAIL PROTECTED] writes: Yes, and surprisingly enough, it's called rename. :) Justin I've had bad luck using rename, I've had to copy the file to Justin the new name and deep six the old, check out File::Copy, I Justin think it ironically, has a function called copy(), or even Justin cp(), my memory eludes me. Well, what was your $! when the rename failed? If it was cross-device link, then you attempted something that you really can't do. But to say in general that rename is perhaps broken is a bit too much for me to let stand with no comment. My advice to the original poster: use rename, but be aware that it can only rename within a disk, not across disks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: String to Date conversion
At 08:42 PM 9/10/2001 -0400, [EMAIL PROTECTED] wrote: Hello, Can some one please suggest me a pointer to do easy date manipulations in perl. I have dates as strigs I need to compare 2 dates and may be sort an array of dates(Strings). Thanks s- Look at the Date modules on CPAN. I quite like one of the recent ones called Class::Date but you'll find that it isn't in ActiveState's PPM repository yet and requires a C compiler to compile if you are using Windows NT. Otherwise consider looking at Date::Manip and Date::Calc. Also, questions like this beg for you to buy the Perl Cookbook from O'Reilly. It has all sorts of quick recipes for Perl for doing operations like this. In addition, you might find some operations are quite trivial. eg if you have a string and you know how to parse it into date parts, you could put the date parts together again in a way that will compare easily in a sort. eg mmdd will sort fairly accurately in scalar context. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Renaming a File
There was DEFINETLY a race condition, I used a technique similar to this: http://www.stonehenge.com/merlyn/WebTechniques/col54.html to solve the problem. There were so many instances where either the live or the temp file would have been overwritten, it wasn't even, well funny. for the curious, this is what the subroutine looks like now, there's way too many file openings for my liking, but it's built for comfort, not good looks :) snip sub remove_from_list { my %args = ( -List = undef, -Path = $lists, -Email_List = undef, -Type = 'list', @_, ); my $list = $args{-List}; my $path = $args{-Path}; my $type = $args{-Type}; my $deep_six = $args{-Email_List}; if($list and $deep_six){ # create the lookup table my %lookup_table; foreach my $going(@$deep_six){ chomp($going); $going = strip($going); $lookup_table{$going} = 1; } # the lookup table holds addresses WE DON'T WANT. SO rememeber that, u my $main_list = $path/$list.$type; my ($sec, $min, $hour, $day, $month, $year) = (localtime)[0,1,2,3,4,5]; my $message_id = sprintf(%02d%02d%02d%02d%02d%02d, $year+1900, $month+1, $day, $hour, $min, $sec); my $temp_list = $main_list.tmp-$message_id; my $count; # this is my big hulking Masterlock that you'll need a shotgun # to blow off. This is me being anal retentive. # # # # sysopen(SAFETYLOCK, $lists/$list.lock, O_RDWR|O_CREAT, $file_chmod) or die Mojo Mail $ver Error - Cannot open list lock file '$lists/$list.lock' - $!; { my $sleep_count = 0; { flock SAFETYLOCK, LOCK_EX | LOCK_NB and last; sleep 1; redo if ++$sleep_count 11; # ok, we've waited 'bout 10 seconds... # nothing's happening, let's say fuck it. warn Mojo Mail $ver Warning: Server is way too busy to unsubscribe people, waited 10 seconds to get access to the list file for $list, giving up: $!\n; return 'too busy'; exit(0); } } # # # # safety lock is set. This should give us a nice big shield to do some file # juggling and updating. I think there is a race condition between when the # the first time the temp and list file are open, and the second time. # This should stop that. wee. #open the original list sysopen(MAIN_LIST, $main_list, O_RDONLY|O_CREAT, $file_chmod) or die Mojo Mail $ver Error: Can't open email list to sort through and make deletions at '$main_list': $!; flock(MAIN_LIST, LOCK_SH) or die Mojo Mail $ver Error: Can't create a exclusive lock to sort through and make deletions at '$main_list': $!; # open a temporary list sysopen(TEMP_LIST, $temp_list, O_RDWR|O_CREAT, $file_chmod) or die Mojo Mail $ver Error: can't create temporary list to sort out deleted e-mails at '$temp_list': $! ; flock(TEMP_LIST, LOCK_EX) or die Mojo Mail $ver Error: can't create an exculsive lock to sort out deleted e-mails at'$temp_list': $! ; my $check_this; while(defined($check_this = MAIN_LIST)){ #lets see, if they pass, send em over. chomp($check_this); $check_this = strip($check_this); # unless its in out delete list, unless(exists($lookup_table{$check_this})){ # print it into the temporary list print TEMP_LIST $check_this, \n; }else{ #missed the boat! $count++; # js - log it $log-mj_log($args{-List},'Unsubscribed from $list.$type', $check_this) if $LOG{subscriptions}; } } close (MAIN_LIST) or die Mojo Mal $ver Error - did not successfully close file '$main_list': $!; close (TEMP_LIST) or die Mojo Mal $ver Error - did not successfully close file '$temp_list': $!; #open the new list, open the old list, copy old to new, done. sysopen(TEMP_LIST, $temp_list, O_RDONLY|O_CREAT, $file_chmod) or die Mojo Mail $ver Error: Can't open temp email list '$temp_list' to copy over to the main list : $!; flock(TEMP_LIST, LOCK_SH) or die Mojo Mail $ver Error: Can't create a exclusive lock to copy over email addresses at '$temp_list': $!; sysopen(MAIN_LIST, $main_list, O_WRONLY|O_TRUNC|O_CREAT, $file_chmod) or die Mojo Mail $ver Error: can't open email list to update '$main_list': $! ; flock(MAIN_LIST, LOCK_EX) or die Mojo Mail $ver Error: can't create an exclusive lock to update '$main_list': $! ; my $passed_email; while(defined($passed_email = TEMP_LIST)){ #lets see, if they pass, send em over. chomp($passed_email); print MAIN_LIST $passed_email, \n; } close
Re: Renaming a File
Justin == Justin Simoni [EMAIL PROTECTED] writes: Yes, and surprisingly enough, it's called rename. :) Justin I've had bad luck using rename, I've had to copy the file to Justin the new name and deep six the old, check out File::Copy, I Justin think it ironically, has a function called copy(), or even Justin cp(), my memory eludes me. Well, what was your $! when the rename failed? If it was cross-device link, then you attempted something that you really can't do. But to say in general that rename is perhaps broken is a bit too much for me to let stand with no comment. My advice to the original poster: use rename, but be aware that it can only rename within a disk, not across disks. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 [EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/ Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]