Re: trouble with meta http-equiv
Wiggins d'Anconia wrote: David Bear wrote: I'm trying to put a client side redirect with http-equiv refresh. I'm using the syntax: my $req = CGI-new(); print $req-header( text/html ); print $req-start_html( -head=meta({-http-equiv = 'refresh', In the above line the call to meta() is a function call, but you have started out with the object syntax. So you likely haven't imported any of the function lists, so you either need to import the correct list, or switch to the object syntax, $req-meta(...) -content = '1;URL=' . $req-refere()})); Note you probably need $req-referer in the above line... Yes, this was it. I am using object syntax, so $req-meta() worked. Yes, the above $req-refere was a type, I am using $req-referer() HTH, http://danconia.org but I get an error: Undefined subroutine %main::meta called This seems to be what is documented on cpan. I must be missing something simple. Any ideas? -- David Bear College of Public Programs at Arizona State University -- -- David Bear College of Public Programs at Arizona State University -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: ways to iterate over params
Bill Jones wrote: On 11/30/06, David Bear [EMAIL PROTECTED] wrote: my $q = CGI-new(); my %params = $q-Vars; foreach $f (keys (%params)) { print $f is $params{$f} ; } use CGI; my $q = CGI-new(); my %params = $q-Vars; foreach my $f (keys (%params)) { print $f is $params{$f}\n; } I was missing my... Thank you very much. -- -- David Bear College of Public Programs at Arizona State University -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
check for def
I would like to do something like (psuedo coded) my $req = CGI-new(); my %params = $req-Vars; if ndef %params { %params = 'gets a hash time that i build' } The goal of course is to make sure that %params has some hash table available even if the script is not called in a cgi environment. Any pointers? -- -- David Bear College of Public Programs at Arizona State University -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: check for def
On 12/01/2006 01:24 PM, David Bear wrote: I would like to do something like (psuedo coded) my $req = CGI-new(); my %params = $req-Vars; if ndef %params { %params = 'gets a hash time that i build' } The goal of course is to make sure that %params has some hash table available even if the script is not called in a cgi environment. Any pointers? if ((keys %params) 1) { %params = ( ... = '...' ); } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: check for def
On 12/1/06, David Bear [EMAIL PROTECTED] wrote: I would like to do something like (psuedo coded) Whats wrong with what you posted previously? The goal of course is to make sure that %params has some hash table available even if the script is not called in a cgi environment. Any pointers? Yes, the 'use CGI' stuff will work even on the command-line (ie, when not used in a CGI/HTTP gateway) environment. HTH/-Sx- -- WC (Bill) Jones -- http://youve-reached-the.endoftheinternet.org/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: check for def
[sorry for following up my own post] On 12/1/06, Bill Jones [EMAIL PROTECTED] wrote: Yes, the 'use CGI' stuff will work even on the command-line (ie, when not used in a CGI/HTTP gateway) environment. A specific example - #! /usr/bin/perl -wT use CGI; use strict; use warnings; use diagnostics; my $q = CGI-new(); my %params = $q-Vars; # See http://hoohoo.ncsa.uiuc.edu/cgi/env.html if ($ENV{GATEWAY_INTERFACE} and $ENV{GATEWAY_INTERFACE} =~ /CGI/i) { print Content-Type: text/html\r\n\r\n ... I'm running as a CGI ...br/; foreach my $key (keys %ENV) { print $key -- $ENV{$key}br/; } } print PRE\n if $ENV{GATEWAY_INTERFACE}; foreach my $f (keys (%params)) { print $f: $params{$f}\n; } print /PRE\n if $ENV{GATEWAY_INTERFACE}; __END__ And on the command-line call it like: perl -wT somefile.pl some variables and params Via the www call it like: http://somehost/some/path/someprog.cgi?varx=varythis=that You get example output like this (via WWW) ... I'm running as a CGI ... SCRIPT_NAME -- /~bjones/index.cgi SERVER_NAME -- fc6.insecurity.org SERVER_ADMIN -- [EMAIL PROTECTED] HTTP_ACCEPT_ENCODING -- gzip,deflate HTTP_CONNECTION -- keep-alive REQUEST_METHOD -- GET HTTP_ACCEPT -- text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 SCRIPT_FILENAME -- /home/bjones/public_html/index.cgi SERVER_SOFTWARE -- Apache/2.2.3 (Debian) mod_python/3.2.10 Python/2.4.4c0 PHP/4.4.4-8 mod_perl/2.0.2 Perl/v5.8.8 HTTP_ACCEPT_CHARSET -- ISO-8859-1,utf-8;q=0.7,*;q=0.7 QUERY_STRING -- varx=varythis=that REMOTE_PORT -- 40145 HTTP_USER_AGENT -- Mozilla/5.0 (X11; U; Linux ppc; en-US; rv:1.8.0.7) Gecko/20060830 Firefox/1.5.0.7 (Debian-1.5.dfsg+1.5.0.7-2) SERVER_PORT -- 80 SERVER_SIGNATURE -- Apache/2.2.3 (Debian) mod_python/3.2.10 Python/2.4.4c0 PHP/4.4.4-8 mod_perl/2.0.2 Perl/v5.8.8 Server at fc6.insecurity.org Port 80 HTTP_ACCEPT_LANGUAGE -- en-us,en;q=0.5 REMOTE_ADDR -- 127.0.1.1 HTTP_KEEP_ALIVE -- 300 SERVER_PROTOCOL -- HTTP/1.1 PATH -- /usr/local/bin:/usr/bin:/bin REQUEST_URI -- /~bjones/index.cgi?varx=varythis=that GATEWAY_INTERFACE -- CGI/1.1 SERVER_ADDR -- 127.0.1.1 DOCUMENT_ROOT -- /var/www/ HTTP_HOST -- fc6.insecurity.org varx: vary this: that -- WC (Bill) Jones -- http://youve-reached-the.endoftheinternet.org/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Complex regex help
Omega -1911 am Freitag, 1. Dezember 2006 06:05: Hello all, I am trying to parse calendar events for a rss feed into variables. Can someone help with building the following regex or point me in the direction of some good examples? Thanks in advance. Here is what I have tried: (I don't know much about complex regex's as you see) $mystring =~ /.+(plib)(\w+) (FONT COLOR=\\#99\)(\w+)(\[Ref \#(\d+\])(.+)$/); Here is a sample string: plib DATE FONT COLOR=#99TITLE/FONT/b EVENT a href= http://www.mysite.comtarget=_new;www.mysite.com/a [Ref #67579]/li What I would like to pull out is the TITLE EVENT information. The sample string is the format for each event. Any takers on this? Again, thanks for any help. If you *really* want do it with a regex, and not a parser (XML::LibXML, XML::Simple, etc.), here is one possibility. However, note that a regex is very fragile if it comes to format changes, or the input has unexpected chars in it. In the regex below, I try to be flexible concerning white space in the input; one could also be more specific in the part following the info to extract. There are generally two somehow contradicting aims: - be most specific to not match unwanted content - be liberal to handle format changes How did you develop the regex? It seems not to match as you liked. One way is to build it step by step; starting with matching strings between p/p, ckecking, be more specific, checking etc. Note that I escape the '#' in the regex because of the /x modifier that allows comments. BEWARE: Id did not spend hours. It just extracts what you want from the $input present. #!/usr/bin/perl use strict; use warnings; my $input=' plib DATE FONT COLOR=#99TITLE1/FONT/b EVENT1 a href=http://www.mysite.comtarget=_new;www.mysite.com/a [Ref #67579]/li/p plib DATE FONT COLOR=#99TITLE2/FONT/b EVENT2 a href=http://www.mysite.comtarget=_new;www.mysite.com/a [Ref #67579]/li/p '; my %info = $input =~ m; p\s* li\s* b.*? font\s*color\s*=\s*\#99[^]*?\s*(.*?)\s*/font\s* /b\s*(.*?)\s*a.*?/a\s*\[ref[^\]]+?\]\s* /li\s* /p ;mgxsi; print map { $_ = $info{$_}\n } sort keys %info; __END__ Dani -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Complex regex help
Omega -1911 wrote: Hello all, I am trying to parse calendar events for a rss feed into variables. Can someone help with building the following regex or point me in the direction of some good examples? Thanks in advance. Here is what I have tried: (I don't know much about complex regex's as you see) $mystring =~ /.+(plib)(\w+) (FONT COLOR=\\#99\)(\w+)(\[Ref \#(\d+\])(.+)$/); Here is a sample string: plib DATE FONT COLOR=#99TITLE/FONT/b EVENT a href= http://www.mysite.comtarget=_new;www.mysite.com/a [Ref #67579]/li What I would like to pull out is the TITLE EVENT information. The sample string is the format for each event. Any takers on this? Again, thanks for any help. Hi Dave Better than using regexes to extract the information, which are notoriously poor at processing HTML, would be to use one of the the bespoke HTML parsing modules. My preference is HTML::TreeBuilder, which builds a structure of HTML::Element objects to represent the original document. From that it is easy to extract the parts you need according to their context. Can you let us have a URL for the information so that we can help you a little better? Or at least an example with several records that you need to process. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Net::EasyTCP
--- zentara [EMAIL PROTECTED] wrote: On Thu, 30 Nov 2006 13:34:16 -0800 (PST), [EMAIL PROTECTED] (Derek B. Smith) wrote: Hello... : ) I need to gather a single filename on hundreds of servers ranging in *UX flavors from AIX, HP, Solaris, RH Linux and Tru64 then store them on on HPUX server. I was initially thinking an scp command like so foreach my $server in (@servers) scp /etc/passwd /tmp/passwd.$SERVER but not all clients have ssh running and other nuances such as no root ssh sign-in, no ftp, and /etc/passwd is protected from downloads and reads by anyone but root. I then looked at Net::EasyTCP for a socket download. As I read the CPAN info and after reading For this to happen do I need to create server and client or just client? What do you recommend? server A would be server which houses gathered files server B would be client which is where unique passwd files live. thank you derek It just so happens I played with this awhile back. Net::EasyTCP is a great time saver, because it handles port passwords, encryption, and serialization of hashes. It's neat to be able to send a hash thru a socket. You have 2 choices. 1. You can have the server RECEIVE files uploaded by the clients. This only requires 1 server to keep a port open, and the clients connect at random and upload their file, like thru a cron job. This is preferable because you only need 1 constantly running socket open to the internet. #OR 2. You can have each client running an open socket, and your collector connects to them and collects the file. I have working examples of both below. Just remember, that Net::EasyTCP uses IO::Select, and if the files are big, the socket will block until the file is uploaded. This wouldn't be a problem if you use option 1. P.S. Use a port password, which Net::EasyTCP makes easy. See: http://perlmonks.org?node_id=198680 Here is a version with a Tk front end: http://perlmonks.org?node_id=387351 And finally, here is another client server pair to use as descibed in option 2 above. (Probably not the best way). I did remember u posting this and saved that email which is why I posted my question. : ) I will probably go with option 1. thank you derek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Can't test without successful make
Hello world I have this problem using perl shell to install cpan modules. I keep getting this Running make test Can't test without successful make Running make install make had returned bad status, install seems impossible I have tried removing the .cpan directory, but this has not made any difference, if someone could assist, I would me most greatful. Kind Regards Brent Clark -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Net::EasyTCP
--- zentara [EMAIL PROTECTED] wrote: On Thu, 30 Nov 2006 13:34:16 -0800 (PST), [EMAIL PROTECTED] (Derek B. Smith) wrote: Hello... : ) I need to gather a single filename on hundreds of servers ranging in *UX flavors from AIX, HP, Solaris, RH Linux and Tru64 then store them on on HPUX server. I was initially thinking an scp command like so foreach my $server in (@servers) scp /etc/passwd /tmp/passwd.$SERVER but not all clients have ssh running and other nuances such as no root ssh sign-in, no ftp, and /etc/passwd is protected from downloads and reads by anyone but root. I then looked at Net::EasyTCP for a socket download. As I read the CPAN info and after reading For this to happen do I need to create server and client or just client? What do you recommend? server A would be server which houses gathered files server B would be client which is where unique passwd files live. thank you derek It just so happens I played with this awhile back. Net::EasyTCP is a great time saver, because it handles port passwords, encryption, and serialization of hashes. It's neat to be able to send a hash thru a socket. You have 2 choices. 1. You can have the server RECEIVE files uploaded by the clients. This only requires 1 server to keep a port open, and the clients connect at random and upload their file, like thru a cron job. This is preferable because you only need 1 constantly running socket open to the internet. #OR 2. You can have each client running an open socket, and your collector connects to them and collects the file. I have working examples of both below. Just remember, that Net::EasyTCP uses IO::Select, and if the files are big, the socket will block until the file is uploaded. This wouldn't be a problem if you use option 1. P.S. Use a port password, which Net::EasyTCP makes easy. Isn't there rules for sending hashes or any data structure over sockets? Does anyone have docs that explain these? thx derek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Can't test without successful make
On 12/1/06, Brent Clark [EMAIL PROTECTED] wrote: I keep getting this Running make test Can't test without successful make That means that the make stage - which builds your new module - didn't succeed, for some reason. Maybe your system is missing some key component, say. Since the module didn't get built, you're stuck. If the CPAN module isn't giving you a diagnostic message with more information about the reason for the failure, you should try installing the module directly, i.e. without the CPAN module. See the new module's README, or use the instructions in the perlmodinstall manpage, at least until you get to a useful diagnostic message. Good luck with it! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Complex regex help
Hi Rob Dani, Thanks for your help!!! I will try the suggestion you made Rob and as soon as I finish typing this, I'll try Dani's code. I had someone by the name of Chen Ken contact me off-list and provided me with the following regex that appeared to work. Please let me know what you think: my( $title, $event) = $data_string =~ m|([^]*)(?:/FONT/b)([^\]]*)([^]*)|;
How can i pull out the first line from every file in a directory
Im working on a perl script to add the IP addresses from spam to my blocked list. Each quarentined email is kept in one directory, the IP address of the sender is in the first line of the headers. Im using O'Reilly's Learning Perl as a guide and got some parts working. I can list all the files in the directory eaisy enough,.. i was going to have that script supply the filename and fire off another script which searched for the IP in individual files,.. I think its a waste of processing power to scan the entire file when i just need the first line. Is there an eaisy way to limit the search to the first line? some code the first one returns each filename in the directory. #!/usr/bin/perl -w use strict; my $file; my $dir = mail/; opendir(BIN, $dir) or die Can't open $dir: $!; while( defined ($file = readdir BIN) ) { next if $file =~ /^\.\.?$/; # skip . and .. print $file\n if -T $dir/$file; } closedir(BIN); - the second one searches a single file for IP addresses. (I left in my failed attempts to get the regex correct,.. figured it might make someone happy to know that there are worse coders out there than themselves) -- #!/usr/bin/perl -w use strict; while (){ if (/\d+\.\d+\.\d+\.\d+/){ #if (/\(*\)/){#search for anything in brackets #if (/\d\.\d\.\d\.\d/){ # search for digit.digit.digit.digit #if (/([1-255]\.[0-255]\.[0-255]\.[0-255])/) { #another atempt print $\n; } } -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Net::EasyTCP
--- zentara [EMAIL PROTECTED] wrote: On Thu, 30 Nov 2006 13:34:16 -0800 (PST), [EMAIL PROTECTED] (Derek B. Smith) wrote: Hello... : ) I need to gather a single filename on hundreds of servers ranging in *UX flavors from AIX, HP, Solaris, RH Linux and Tru64 then store them on on HPUX server. I was initially thinking an scp command like so foreach my $server in (@servers) scp /etc/passwd /tmp/passwd.$SERVER but not all clients have ssh running and other nuances such as no root ssh sign-in, no ftp, and /etc/passwd is protected from downloads and reads by anyone but root. I then looked at Net::EasyTCP for a socket download. As I read the CPAN info and after reading For this to happen do I need to create server and client or just client? What do you recommend? server A would be server which houses gathered files server B would be client which is where unique passwd files live. thank you derek It just so happens I played with this awhile back. Net::EasyTCP is a great time saver, because it handles port passwords, encryption, and serialization of hashes. It's neat to be able to send a hash thru a socket. You have 2 choices. 1. You can have the server RECEIVE files uploaded by the clients. This only requires 1 server to keep a port open, and the clients connect at random and upload their file, like thru a cron job. This is preferable because you only need 1 constantly running socket open to the internet. #OR 2. You can have each client running an open socket, and your collector connects to them and collects the file. I have working examples of both below. Just remember, that Net::EasyTCP uses IO::Select, and if the files are big, the socket will block until the file is uploaded. This wouldn't be a problem if you use option 1. P.S. Use a port password, which Net::EasyTCP makes easy. See: http://perlmonks.org?node_id=198680 Here is a version with a Tk front end: http://perlmonks.org?node_id=387351 ok but is it possible to emulate an ftp get from the master to retreive files from all clients w/out deploying the client code to all clients using this module? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: How can i pull out the first line from every file in a directory
Dennis Bourn wrote: Im working on a perl script to add the IP addresses from spam to my blocked list. Each quarentined email is kept in one directory, the IP address of the sender is in the first line of the headers. Im using O'Reilly's Learning Perl as a guide and got some parts working. I can list all the files in the directory eaisy enough,.. i was going to have that script supply the filename and fire off another script which searched for the IP in individual files,.. I think its a waste of processing power to scan the entire file when i just need the first line. Is there an eaisy way to limit the search to the first line? some code the first one returns each filename in the directory. #!/usr/bin/perl -w use strict; my $file; my $dir = mail/; opendir(BIN, $dir) or die Can't open $dir: $!; while( defined ($file = readdir BIN) ) { next if $file =~ /^\.\.?$/; # skip . and .. print $file\n if -T $dir/$file; } closedir(BIN); - the second one searches a single file for IP addresses. (I left in my failed attempts to get the regex correct,.. figured it might make someone happy to know that there are worse coders out there than themselves) -- #!/usr/bin/perl -w use strict; while (){ if (/\d+\.\d+\.\d+\.\d+/){ #if (/\(*\)/){#search for anything in brackets #if (/\d\.\d\.\d\.\d/){ # search for digit.digit.digit.digit #if (/([1-255]\.[0-255]\.[0-255]\.[0-255])/) { #another atempt print $\n; } } -- I finally made it to page 132 in Learning Perl and discovered the command line syntax. perl -n -w -e 'if (/\d+\.\d+\.\d+\.\d+/){ print $\n;}' mail/mail* that single command does most of what i need, I can just pipe the output to pfctl to add it to the firewall block list. however i still have the problem of it checking the entire file instead of the first line. In addition im seeing a version number in the headers like V6.2000.20.5 which matches my regular expresion. If i can narrow it down to the first line of the file this wont be a problem. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: How can i pull out the first line from every file in a directory
Dennis Bourn wrote: Im working on a perl script to add the IP addresses from spam to my blocked list. Each quarentined email is kept in one directory, the IP address of the sender is in the first line of the headers. Im using O'Reilly's Learning Perl as a guide and got some parts working. I can list all the files in the directory eaisy enough,.. i was going to have that script supply the filename and fire off another script which searched for the IP in individual files,.. I think its a waste of processing power to scan the entire file when i just need the first line. Is there an eaisy way to limit the search to the first line? some code the first one returns each filename in the directory. #!/usr/bin/perl -w use strict; my $file; my $dir = mail/; opendir(BIN, $dir) or die Can't open $dir: $!; while( defined ($file = readdir BIN) ) { next if $file =~ /^\.\.?$/; # skip . and .. print $file\n if -T $dir/$file; } closedir(BIN); - the second one searches a single file for IP addresses. (I left in my failed attempts to get the regex correct,.. figured it might make someone happy to know that there are worse coders out there than themselves) -- #!/usr/bin/perl -w use strict; while (){ if (/\d+\.\d+\.\d+\.\d+/){ #if (/\(*\)/){#search for anything in brackets #if (/\d\.\d\.\d\.\d/){ # search for digit.digit.digit.digit #if (/([1-255]\.[0-255]\.[0-255]\.[0-255])/) { #another atempt print $\n; } } -- #!/usr/bin/perl use warnings; use strict; my $dir = 'mail'; opendir BIN, $dir or die Can't open $dir: $!; while ( defined( my $file = readdir BIN ) ) { next unless -f $dir/$file and -T $dir/$file; open FILE, '', $dir/$file or die Can't open $dir/$file: $!; # only read first line of file my ( $ip ) = FILE =~ /(\d+\.\d+\.\d+\.\d+)/; close FILE; do_something_with( $ip ); } closedir BIN; John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order. -- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Question regarding use of multiple Perl versions
On Thu, 2006-11-30 at 11:40 -0500, Hotz, Harry wrote: I have a new AIX 5.3 server that comes with a default Perl 5.82. I have a DB2 programmer that has scripts from an old AIX 4.3 server that used Perl 5.005_03. He will have to rewrite his scripts to use the new Perl and asked me to install the old version side by side. I did so in a directory and compiled it successfully. He took the user account under which the scripts are executing and added a path to the profile to point to the location of the old Perl but when he uses it and does a perl -version he still gets a return of the 5.8 version. He feels this is a guarantee that his scripts will be hitting the wrong version and wants to know why he cannot version query the old Perl. My question is it even possible to successfully work with two PATH=/usr/lpp/oldperl:$PATH rather than the normal PATH=$PATH:/usr/lpp/oldperl then he prefixes every command with `perl script` As others have pointed out the #! normally points to /usr/bin/perl and if you cannot prefix calls with perl then you have to change that. -- Ken Foskey FOSS developer -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Can't test without successful make
On 12/01/2006 08:13 AM, Brent Clark wrote: Hello world I have this problem using perl shell to install cpan modules. I keep getting this Running make test Can't test without successful make Running make install make had returned bad status, install seems impossible I have tried removing the .cpan directory, but this has not made any difference, if someone could assist, I would me most greatful. Kind Regards Brent Clark Surely you got more descriptive errors than that. What were they? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: How can i pull out the first line from every file in a directory
On 12/01/2006 02:01 PM, Dennis Bourn wrote: Dennis Bourn wrote: Im working on a perl script to add the IP addresses from spam to my blocked list. Each quarentined email is kept in one directory, the IP address of the sender is in the first line of the headers. Im using O'Reilly's Learning Perl as a guide and got some parts working. I can list all the files in the directory eaisy enough,.. i was going to have that script supply the filename and fire off another script which searched for the IP in individual files,.. I think its a waste of processing power to scan the entire file when i just need the first line. Is there an eaisy way to limit the search to the first line? some code the first one returns each filename in the directory. #!/usr/bin/perl -w use strict; my $file; my $dir = mail/; opendir(BIN, $dir) or die Can't open $dir: $!; while( defined ($file = readdir BIN) ) { next if $file =~ /^\.\.?$/; # skip . and .. print $file\n if -T $dir/$file; } closedir(BIN); - the second one searches a single file for IP addresses. (I left in my failed attempts to get the regex correct,.. figured it might make someone happy to know that there are worse coders out there than themselves) -- #!/usr/bin/perl -w use strict; while (){ if (/\d+\.\d+\.\d+\.\d+/){ #if (/\(*\)/){#search for anything in brackets #if (/\d\.\d\.\d\.\d/){ # search for digit.digit.digit.digit #if (/([1-255]\.[0-255]\.[0-255]\.[0-255])/) { #another atempt print $\n; } } -- I finally made it to page 132 in Learning Perl and discovered the command line syntax. perl -n -w -e 'if (/\d+\.\d+\.\d+\.\d+/){ print $\n;}' mail/mail* that single command does most of what i need, I can just pipe the output to pfctl to add it to the firewall block list. however i still have the problem of it checking the entire file instead of the first line. In addition im seeing a version number in the headers like V6.2000.20.5 which matches my regular expresion. If i can narrow it down to the first line of the file this wont be a problem. Use the Regexp::Common::net module for this. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Complex regex help
Omega -1911 am Freitag, 1. Dezember 2006 19:01: Hi Rob Dani, Hello Omega Thanks for your help!!! I will try the suggestion you made Rob and as soon as I finish typing this, I'll try Dani's code. I had someone contact me off-list and provided me with the following regex that appeared to work. Please let me know what you think: my( $title, $event) = $data_string =~ m|([^]*)(?:/FONT/b)([^\]]*)([^]*)|; First I'd like to emphasize that Rob's suggestion (use a parser module, not a regex) is really the preferred way. Consequently, I should not have mentioned a regex... I see at least the following problems with the above regex (there are others, as well as in mine): - It captures three peaces of the input, while on the left side are only two variables to put the peaces in. - When I run it, it matches too much into $event (event up to the Ref # without the trailing ']' - the latter is put in $3). - ... In short: A parser module will avoid a lot of trickiness, pitfalls, error proneness, problems [pick the right english term(s) if present] :-) Just forget the regex path. Dani -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Net::EasyTCP
Derek B. Smith am Freitag, 1. Dezember 2006 20:31: --- zentara [EMAIL PROTECTED] wrote: On Thu, 30 Nov 2006 13:34:16 -0800 (PST), [EMAIL PROTECTED] I need to gather a single filename on hundreds of servers ranging in *UX flavors from AIX, HP, [snip] I was initially thinking an scp command like so foreach my $server in (@servers) scp /etc/passwd /tmp/passwd.$SERVER but not all clients have ssh running and other nuances such as no root ssh sign-in, no ftp, and /etc/passwd is protected from downloads and reads by anyone but root. [snip] See: http://perlmonks.org?node_id=198680 Here is a version with a Tk front end: http://perlmonks.org?node_id=387351 ok but is it possible to emulate an ftp get from the master to retreive files from all clients w/out deploying the client code to all clients using this module? Hi Derek, Sorry for not providing an answer to your question (I *think* your question is answered by the manual. If not, wait for zentara :-) ) I may miss something but it may make the person(s) who are responsible for security nervous to hear of plans/thoughts - to transfer hundreds of passwd files unencrypted over the network - to place them in the /tmp directory with predictable file names - of seeing disallowed root login, locked down files, and missing ftp as a problem At least I would get nervous (although not having access to hundreds of boxes...) Dani -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Complex regex help
Omega -1911 wrote: Hi Rob Dani, Thanks for your help!!! I will try the suggestion you made Rob and as soon as I finish typing this, I'll try Dani's code. I had someone by the name of Chen Ken contact me off-list and provided me with the following regex that appeared to work. Please let me know what you think: my( $title, $event) = $data_string =~ m|([^]*)(?:/FONT/b)([^\]]*)([^]*)|; Hello Dave You will need help to use HTML::TreeBuilder as it's fairly complex, and to help you we need fuller information on the HTML you're processing. Can you publish a bigger chunk? Or, better still, the URL where it is coming from? The regex doesn't look right at all, the (?: .. ) around the closing font and bold tags has no effect, and the ] in the character class needn't be escaped. Apart from that it will grab everything from EVENT up to the end of the Ref # value into $event and the closing ] into $3 which is then discarded. Not good at all. Against my better judgement I could offer my @stuff = $data =~ /\s*([^]+)\s*/g; which will return all the text between the HTML tags, but this will fall down if you have something like i.../i in the middle of one of the fields, which will result in the text being broken into multiple segments. Better all round to use a proper parser. HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Limit of number of files that can be opened in perl
Hi: is there a limit on number of files that can be open within perl. I am opening about 194 files and am seeing some weird behaviour. When i write to the filehandles, I see it writes ok to some files and not to the others. But I donot see any errors either. Just that somefiles donot have what I am expecting. If there is a limit, how do I work around it? Thanks Ravi Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Limit of number of files that can be opened in perl
On Fri, 1 Dec 2006 18:46:38 -0800 (PST) Ravi Malghan [EMAIL PROTECTED] wrote: Hi: is there a limit on number of files that can be open within perl. I am opening about 194 files and am seeing some weird behaviour. When i write to the filehandles, I see it writes ok to some files and not to the others. But I donot see any errors either. Just that somefiles donot have what I am expecting. If there is a limit, how do I work around it? Generally there are system limitations, but 194 files should be of no consequence. What debugging do you have in place, error messages etc? If some files aren't being written to, where are they being written (Hint: have you checked the return value of your write statement?) Owen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Limit of number of files that can be opened in perl
Ravi Malghan wrote: Hi: is there a limit on number of files that can be open within perl. I am opening about 194 files and am seeing some weird behaviour. When i write to the filehandles, I see it writes ok to some files and not to the others. But I donot see any errors either. Just that somefiles donot have what I am expecting. If there is a limit, how do I work around it? If you are on Unix/Linux: man ulimit John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order. -- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Net::EasyTCP
On 11/30/06, Derek B. Smith [EMAIL PROTECTED] wrote: but not all clients have ssh running and other nuances such as no root ssh sign-in, no ftp, and /etc/passwd is protected from downloads and reads by anyone but root. Well, since we seem to be going down this path -- you could try hacking around with the fish protocol: http://linuxmafia.com/faq/Security/fish-protocol.html Maybe make it work even if ssh doesn't ... -- WC (Bill) Jones -- http://youve-reached-the.endoftheinternet.org/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Net::EasyTCP
--- D. Bolliger [EMAIL PROTECTED] wrote: Derek B. Smith am Freitag, 1. Dezember 2006 20:31: --- zentara [EMAIL PROTECTED] wrote: On Thu, 30 Nov 2006 13:34:16 -0800 (PST), [EMAIL PROTECTED] I need to gather a single filename on hundreds of servers ranging in *UX flavors from AIX, HP, [snip] I was initially thinking an scp command like so foreach my $server in (@servers) scp /etc/passwd /tmp/passwd.$SERVER but not all clients have ssh running and other nuances such as no root ssh sign-in, no ftp, and /etc/passwd is protected from downloads and reads by anyone but root. [snip] See: http://perlmonks.org?node_id=198680 Here is a version with a Tk front end: http://perlmonks.org?node_id=387351 ok but is it possible to emulate an ftp get from the master to retreive files from all clients w/out deploying the client code to all clients using this module? Hi Derek, Sorry for not providing an answer to your question (I *think* your question is answered by the manual. If not, wait for zentara :-) ) I may miss something but it may make the person(s) who are responsible for security nervous to hear of plans/thoughts - to transfer hundreds of passwd files unencrypted over the network - to place them in the /tmp directory with predictable file names - of seeing disallowed root login, locked down files, and missing ftp as a problem At least I would get nervous (although not having access to hundreds of boxes...) Dani I can understand you comments, but I am behind several firewalls, I changed it from /tmp to my home dir with permissions of 400. scp is being used as a work-around while a manual login will have to be done for those systems that do not have ssh turned on. I was hoping for socket data transfers to mimic an sftp/ftp get without having to deploy code to the clients and or deploying this module on the clients. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Limit of number of files that can be opened in perl
bash-2.05$ ulimit -a core file size (blocks) unlimited data seg size (kbytes) unlimited file size (blocks) unlimited open files 256 pipe size (512 bytes) 10 stack size (kbytes) 8192 cpu time (seconds) unlimited max user processes 29995 virtual memory (kbytes) unlimited Looks like I can open only 256 files. Anyway I can get around within perl without changing the actual limit on the operating system. Thanks Ravi - Original Message From: John W. Krahn [EMAIL PROTECTED] To: Perl Beginners beginners@perl.org Sent: Friday, December 1, 2006 10:16:58 PM Subject: Re: Limit of number of files that can be opened in perl Ravi Malghan wrote: Hi: is there a limit on number of files that can be open within perl. I am opening about 194 files and am seeing some weird behaviour. When i write to the filehandles, I see it writes ok to some files and not to the others. But I donot see any errors either. Just that somefiles donot have what I am expecting. If there is a limit, how do I work around it? If you are on Unix/Linux: man ulimit John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order. -- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response Any questions? Get answers on any topic at www.Answers.yahoo.com. Try it now. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response