Display timing
First of all I just started using cgi last week. So, if you see something strange in my code it would be lack of knowledge. Here is the question: I have some lines that display stuff, then do more code, then display more stuff. Is there a way to get the first stuff displayed before the other code runs? here is an example: #!/usr/bin/perl use strict; use warnings; use diagnostics; use CGI qw(:standard); #I really do not understand the qw use CGI::Carp qw(fatalsToBrowser);# or the qw here sub Main { my ($test, $pop3pass); print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "User Testing\n"; print "\n"; print "\n"; print "print 1st line\n"; sleep(30); print "print 2nd line\n"; print "back\n"; print "\n"; print "\n"; } Main(); #33 Nothing displays until after the script is done. thanks Rod. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Display timing
###3 Rod, "qw" stands for "Quoted Words". Something like :standard is called a 'bareword'. A bareword is something that is not recognized by the perl parser. qw does the quoteing for you. "use CGI qw(:standard);" is the same as writing "use CGI ':standard';" As for the reason that it doesn't display until the script is finished. That is a web browser issue. Some browsers (Not mentioning any names Microsoft) wait until they see '' to display. Really good Webbrowsers like Mozilla, Netscape, Opera will display as they recieve information. That 30 second sleep is hosing your internet explorer. Also, since you are using the CGI module, try using it's functions. Se my untested modifications on your functions below.. Ciao, Kristofer. = #!/usr/bin/perl use strict; use warnings; use diagnostics; use CGI qw(:standard); #I really do not understand the qw use CGI::Carp qw(fatalsToBrowser);# or the qw here sub Main { my ($test, $pop3pass); print header(), start_html({-title => 'User Testing'}), "Print 1st line", br(), "Print 2nd line", br(), end_html(); } Main(); 1; = -BEGIN GEEK CODE BLOCK- Version: 3.12 GIT d s+:++ a C++ UL++ US+ P+++ L++ W+++ w PS PE t++ b+ G e r+++ z --END GEEK CODE BLOCK-- __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Display timing
Rod Jenkins <[EMAIL PROTECTED]> wrote: : : First of all I just started using cgi last week. : So, if you see something strange in my code it : would be lack of knowledge. : Here is the : question: : : I have some lines that display stuff, then do : more code, then display more stuff. Is there : a way to get the first stuff displayed before : the other code runs? here is an example: Your running into a problem with the buffer. Perl's buffer is controlled by the special perl variable '$|'. You can read more about it in 'perlvar'. Block buffered output is the default. To set STDOUT to line buffer output change '$|' to a non-zero value. : #!/usr/bin/perl : use strict; : use warnings; : use diagnostics; Wow, you read the right books! Add: $|++; Or: $| = 1; : use CGI qw(:standard); #I really do not understand the qw : use CGI::Carp qw(fatalsToBrowser);# or the qw here 'qw' is described in 'perlop' under the Quote and Quote-like Operators section. I think of it as the "quote word" function because it puts single quotes around each word it finds. The list following a 'use Module' call is sent to a subroutine of the module called 'import'. import usually imports something into the scripts namespace. use CGI qw(:standard); Imports a large group of functions. You can import individual functions by not preceding them with ':'. Take a look at the CGI.pm documentation to get all the details. In your program the line is not needed. You are not using CGI.pm functions. use CGI::Carp qw(fatalsToBrowser); This line will send your errors to the browser. Normally they go to your logs and you get a 500 server error in the browser. This line is considered insecure once your script goes into production. Welcome to perl, Charles K. Clarkson -- Head Bottle Washer, Clarkson Energy Homes, Inc. Mobile Home Specialists 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Display timing
On 10 Jul 2003 10:41:54 -0500, Rod Jenkins wrote: > First of all I just started using cgi last week. So, if you see > something strange in my code it would be lack of knowledge. Here is the > question: > > I have some lines that display stuff, then do more code, then display > more stuff. Is there a way to get the first stuff displayed before the > other code runs? here is an example: Hello Rod, there is a way to set the buffer to autoflush... You can disable le buffering by setting $| (dollar-pipe) to a true value, customarily 1. E.g.: $| = 1; You also might want to follow up with an immediate output of the http header. E.g.: print "Content-type: text/html\n\n"; thanks /oliver -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Display timing
I have done perl for awhile, but I was self taught. I did what works, now I am trying to do it right. IE: With style. Thanks for the info. > Welcome to perl, -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
select multiple
Beginners-CGI; If I have a form with a lot of values (such as Tech ID, Tech Name, Tech Queues..) and one of the fields is a select multiple, with a varied amount of options selected, how are those values sent to the cgi script? Is it something like ?queue=lvl1,lvl2,admin,sysad&foo=bar or what? Thanks Dennis -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: select multiple
On Thu, 10 Jul 2003 11:39:23 -0800, "Dennis Stout" <[EMAIL PROTECTED]> wrote: > Beginners-CGI; > > If I have a form with a lot of values (such as Tech ID, Tech Name, Tech > Queues..) and one of the fields is a select multiple, with a varied amount of > options selected, how are those values sent to the cgi script? > > Is it something like ?queue=lvl1,lvl2,admin,sysad&foo=bar or what? > Because there is no way to create a delimiter that the potential data doesn't contain, the browser doesn't have the option to choose an arbitrary delimiter like a comma, or the like. So (though I can't speak for all browsers most will do the same) each value is passed with the same key, so your string ends up like: ?queue=lvl1&queue=lvl2&queue=admin&queue=sysad&foo=bar This punts the problem to the server side (or whatever does the query string parsing) so there are multiple ways to handle it, build a complex data structure that stores an array reference for any multi-valued keys, store the keys with some known delimiter (aka cgi-lib.pl used to use the null character \0). So it depends on your request parser, some provide multiple manners (I think the standard CGI does). Have a look at the respective docs for how your parser handles it, unless you are writing a parser...but then why do that with so many good freely available ones? http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: select multiple
> Because there is no way to create a delimiter that the potential data doesn't contain, the browser doesn't have the option to choose an arbitrary delimiter like a comma, or the like. So (though I can't speak for all browsers most will do the same) each value is passed with the same key, so your string ends up like: > > ?queue=lvl1&queue=lvl2&queue=admin&queue=sysad&foo=bar > > This punts the problem to the server side (or whatever does the query string parsing) so there are multiple ways to handle it, build a complex data structure that stores an array reference for any multi-valued keys, store the keys with some known delimiter (aka cgi-lib.pl used to use the null character \0). So it depends on your request parser, some provide multiple manners (I think the standard CGI does). Have a look at the respective docs for how your parser handles it, unless you are writing a parser...but then why do that with so many good freely available ones? Interesting. So in mod_perl, I would use $r->args{__what__} to get to it? Heh. I'll email the mod_perl list.. Dennis -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Net::FTP
#!/usr/bin/perl -w use strict; use warnings; use CGI::Carp 'fatalsToBrowser'; use CGI qw/:standard/; use Net::FTP; my $ftp = Net::FTP->new("ftp.yourserver.com", Debug => 0) or die "Cannot connect to some.host.name: $@"; $ftp->login("username",'password') or die "Cannot login ", $ftp->message; $ftp->cwd("/") or die "Cannot change working directory ", $ftp->message; my @Directory = $ftp->dir("/path/to/directory"); print "@Directory"; $ftp->quit; I am using the following to login to remote FTP; and its working fine and I am getting the list of files from remote FTP from my desired directory but; - The script is working fine in my Window IDE and giving an Internal Server Error (without any error message) while on my Host. - its returning @Directory in long format "-rw-r--r-- 1 username username 8654 Jul 5 18:20 test.html" Is it possible to get file names only like test.html and how to provide $Directory in the script given below because above is an array context @Directory? because after getting the list of files from the directory above I want to match/compare the file names with a text list on my server, see below. ### $my Directory = "."; if ( open( NO, 'data.txt' ) ) { while ( ) { chomp; # Optional: Add check for blank/incomplete lines. if ( -f "$Directory/$_" ) { print "File '$_' exists in '$Directory'.\n"; # Optional: Add file to 'exists' list for later reporting. } else { print "File '$_' does NOT exist in '$Directory'.\n"; # Optional: Add file to 'not exists' list for later reporting. } } close( NO ); } else { print "ERROR: Unable to open file: $!\n"; } Thanks, SARA.
Re: select multiple
ARHG. I want to stay as far away from use CGI; as possible =/ *sigh* mod_perl and the methods available in the apache request object shuold beable to replace CGI.pm entirely, especially when you have a highly customized RequestHandler :/ Guess I'll see what happens, since I need cookie headers to work AND now multiple values for one param. S.T.O.U.T. = Synthetic Technician Optimized for Ultimate Troublshooting - Original Message - From: "Chris Faust" <[EMAIL PROTECTED]> To: "Dennis Stout" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Thursday, July 10, 2003 16 30 Subject: Re: select multiple > CGI.pm does the trick for me, the multi values are seperated by \0 > > < select name="yadda" multi> > yadda1 > yadda2 > yadda3 > > > > my $CGI = new CGI(); > %form_data = $CGI->Vars; > > @options = split("\0",$form_data{'yadda'}); > > $options[0] = yadda1, $options[1] = yadda2 etc . > > Not usable live code obviously, but you should see the idea... > > -Chris > - Original Message - > From: "Dennis Stout" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>; > <[EMAIL PROTECTED]> > Sent: Thursday, July 10, 2003 4:52 PM > Subject: Re: select multiple > > > > > > Interesting. > > > > So in mod_perl, I would use $r->args{__what__} to get to it? Heh. > > > > I'll email the mod_perl list.. > > > > Dennis > > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: select multiple
Dennis Stout wrote: ARHG. I want to stay as far away from use CGI; as possible =/ *sigh* mod_perl and the methods available in the apache request object shuold beable to replace CGI.pm entirely, especially when you have a highly customized RequestHandler :/ Guess I'll see what happens, since I need cookie headers to work AND now multiple values for one param. Probably best to try and see. Setup a simple handler that calls $r->args in list context and then step through the elements and see how they are arranged. I poked around in the 1.0 docs but wasn't able to come up with anything concrete, you might also mention which version of mod_perl you are dealing with http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
checkbox label font
Greetings, In a checkbox form, how can I change the attribute for the "label" text below to Arial instead of the default? $cgi->checkbox(-name=>'checkboxname',-value=>'turned on',-label=>"I want Arial here"); Thank you. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Hiding Params in url
I have an application that passes params around in the url. We need to hide these for security reasons. We also don't want to have to change a lot of code. Any ideas? Thanks, Ryan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [cgiapp] Hiding Params in url
On Thu, Jul 10, 2003 at 01:29:06PM -0500, ryan whippo wrote: > I have an application that passes params around in the url. We need to > hide these for security reasons. We also don't want to have to change a > lot of code. Any ideas? Hiding params doesn't add any level of real security. So long as you are working with an HTML page, the end user can easily see what parameters are being passed, and can easily try sending different values for parameters. The common method for "secure" params is to: 1) Never trust anything you get from the user. Perl's taint option can help remind you of this, but you need to understand WHY you shouldn't trust it. I can list many examples of bad ideas, but without knowing anything about your application, I'm not sure what examples to use. But in general terms, any statement you use user-supplied data in can be taken over if you don't check the data. If you are trying to drop a table name in an SQL statement, they can run any SQL statement. If you are reading a given file, they can read any file your webserver can read. If you are executing a shell command, they can wipe your files. There are, however, several standard and semi-standard ways of preventing this that aren't difficult. See the perlsec man page for more on this topic. 2) Any values that you don't want the user to be able to modify at whim should be stored server-side (by any number of means, see CGI::Session or Apache::Session for examples). Only a SessionID needs to be sent to the user (Via cookie or as a param -- this is a long lasting debate, but both work). Sorry, but you can't hide params in HTML...any attempt to do so will lead to a false sense of security. Far easier to secure the use of the params or use server-side that is free from tampering. -- SwiftOne / Brett Sanger [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Hiding Params in url
On Thu, Jul 10, 2003 at 01:29:06PM -0500, ryan whippo wrote: > I have an application that passes params around in the url. We need to > hide these for security reasons. We also don't want to have to change a > lot of code. Any ideas? Yes... don't do this. Anything in the URL is visible, as is anything in a web page you send to a client that generated the form reply. If it's for security, keep the private data on the server, and refer to it with a "session ID". If you really must use a cgi parameter, use a hidden field on the form, and encrypt the data, including a checksum, so users can't easily change it. But assume that at least a few will find out how to change it anyway. Liam -- Liam Quin, W3C XML Activity Lead, [EMAIL PROTECTED], http://www.w3.org/People/Quin/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Hiding Params in url
At 01:29 PM 7/10/03 -0500, ryan whippo wrote: I have an application that passes params around in the url. We need to hide these for security reasons. We also don't want to have to change a lot of code. Any ideas? Ryan, I presume that you mean you are using the GET method (which tacks the parameters onto the end of the URL (after '?'). If you use the POST method (look at your FORM tag) the parameters will not appear. However, they still can be visible to any user who does a 'Show Source'. It is possible for a user to change parameters and values that are in HTML forms. If you are concerned about security you need to do things differently. Note: This was read on the perl-xml list. This is not really an XML topic. I am not on the other Perl lists. If you have any questions, please directly email me. + | Leonard Daly <[EMAIL PROTECTED]> | Internet Development http://realism.com/ | e3D News Technical Editor http://e3dNews.com/ | SIGGRAPH 2002&2003 X3D Course Organizer | X3D Specification Co-Author +--
Re: Hiding Params in url
POST versus GET. POST won't pass the value in the url. This doesn't prevent someone from doing a view source and reading the text, but A crypt() on the parameters would be a good idea, then pass the encrypted string around. S.T.O.U.T. = Synthetic Technician Optimized for Ultimate Troublshooting - Original Message - From: "ryan whippo" <[EMAIL PROTECTED]> To: "'Perl Beginners '" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Thursday, July 10, 2003 10 29 Subject: Hiding Params in url > I have an application that passes params around in the url. We need to > hide these for security reasons. We also don't want to have to change a > lot of code. Any ideas? > Thanks, > Ryan > > > > -- > 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]