exec() confirmation
Howdy list what a beautifull Monday eh? I have shell commands I need run from a list that Perl creates based on a database. What I want to do is execute each command and regardless of what happens to the external program keep running my perl script. If I understand it right I need exec() for that. So If I do this : for(@cmds) { exec($_); } It will execute $_ and keep cruising regardless of if $_ worked, failed, wasn't found, etc.. Correct? TIA Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: exec() confirmation
Dan Muey wrote: Howdy list what a beautifull Monday eh? I have shell commands I need run from a list that Perl creates based on a database. What I want to do is execute each command and regardless of what happens to the external program keep running my perl script. If I understand it right I need exec() for that. Yes, but you need to fork() first. exec() replaces your current program with a new one, so you need to create a new process with fork(), then exec() the program. So If I do this : for(@cmds) { exec($_); } It will execute $_ and keep cruising regardless of if $_ worked, failed, wasn't found, etc.. No. See: perldoc -q background perldoc -f exec perldoc -f fork perldoc perlipc -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: exec() confirmation
So If I do this : for(@cmds) { exec($_); } It will execute $_ and keep cruising regardless of if $_ worked, failed, wasn't found, etc.. Correct? Nope :) exec() will replace your running perl interpreter with the program you're running, so that wouldn't have the effect you wanted. If you want to run the commands one after the other, use system() instead, just make sure that the input isn't actually going to do anything crazy (like rm -rf /). Optionally, you can use exec() but then you'll have to fork() first, and the child exec()'s the command. -- Bernhard van Staveren - madcat(at)ghostfield.com GhostField Internet - http://www.ghostfield.com/ A witty saying proves nothing, but damn it's funny! - me, 1998 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: exec() confirmation
So If I do this : for(@cmds) { exec($_); } It will execute $_ and keep cruising regardless of if $_ worked, failed, wasn't found, etc.. Correct? Nope :) exec() will replace your running perl interpreter with the program you're running, so that wouldn't have the effect you wanted. If you want to run the commands one after the other, use system() instead, just make sure that the input isn't actually going to do anything crazy (like rm -rf /). Very true, actually I am doing the same command that is hardcoded, just adding a \w+ string as an argument each time. Optionally, you can use exec() but then you'll have to fork() first, and the child exec()'s the command. Thanks for the insight! Dan -- Bernhard van Staveren - madcat(at)ghostfield.com GhostField Internet - http://www.ghostfield.com/ A witty saying proves nothing, but damn it's funny! - me, 1998 -- 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: exec() confirmation
Dan Muey wrote: Howdy list what a beautifull Monday eh? I have shell commands I need run from a list that Perl creates based on a database. What I want to do is execute each command and regardless of what happens to the external program keep running my perl script. If I understand it right I need exec() for that. Yes, but you need to fork() first. exec() replaces your current program with a new one, so you need to create a new process with fork(), then exec() the program. So If I do this : for(@cmds) { exec($_); } It will execute $_ and keep cruising regardless of if $_ worked, failed, wasn't found, etc.. No. See: Will do, thanks for the info! Dan perldoc -q background perldoc -f exec perldoc -f fork perldoc perlipc -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Confirmation...
In article 01ad01c17ee7$dcbfff80$5960a9cb@nothing, [EMAIL PROTECTED] (Leon) wrote: This /([\d.]*)\/.*/g works irregardless whether your ip is 206.48.16.3/12345 or src=206.48.16.3/12345 it doesn't work at all, actually. -- brian d foy [EMAIL PROTECTED] - Perl services for hire CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Confirmation...
I'm a beginner in those regular expressions and s/// operations. How can I extract only the digits and the periods (.) from a string ? I have something like 206.48.16.3/12345. An IP address with a port number. There are digits on both sides of the slash, but I would like to keep only the digits from on the left as well as the periods. More complex question: If I have something like src=206.48.16.3/12345, how can I do the same as bove, but also removing the src= at the beginning ? Thanks :-) Jean-Francois Messier Ottawa, CANADA -Original Message- From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 05, 2001 11:18 PM To: Daniel Falkenberg Cc: [EMAIL PROTECTED] Subject: Re: Confirmation... On Dec 6, Daniel Falkenberg said: $string =~ s/[^a-zA-Z0-9]//g; I take it only allows $string to eq anthing in the charcter class of a-z, A-Z and 0-9. I also take it that anything other than that will be stripped out? Any other comments? Right. I'd write it as s/[^a-zA-Z0-9]+//g; for efficiency. Or perhaps as tr/a-zA-Z0-9//cd; for clarity. Your ideas of efficiency and clarity may differ. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** stu what does y/// stand for? tenderpuss why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Breakout of Ip Address ( was RE: Confirmation...)
using a regex like : /^src=((\d+\.){3}\d+)\// Starts at beginning of variable with src= then place in $1 3 sets of digitrs followed by a period and another set of digits followed by a / Now you could have the port check as part of the regex, but that would be up to you. Assumes the search is being done on $_ Wags ;) -Original Message- From: Messier, Jean-Francois [mailto:[EMAIL PROTECTED]] Sent: Thursday, December 06, 2001 08:07 To: '[EMAIL PROTECTED]'; Daniel Falkenberg Cc: [EMAIL PROTECTED] Subject: RE: Confirmation... I'm a beginner in those regular expressions and s/// operations. How can I extract only the digits and the periods (.) from a string ? I have something like 206.48.16.3/12345. An IP address with a port number. There are digits on both sides of the slash, but I would like to keep only the digits from on the left as well as the periods. More complex question: If I have something like src=206.48.16.3/12345, how can I do the same as bove, but also removing the src= at the beginning ? Thanks :-) Jean-Francois Messier Ottawa, CANADA -Original Message- From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 05, 2001 11:18 PM To: Daniel Falkenberg Cc: [EMAIL PROTECTED] Subject: Re: Confirmation... On Dec 6, Daniel Falkenberg said: $string =~ s/[^a-zA-Z0-9]//g; I take it only allows $string to eq anthing in the charcter class of a-z, A-Z and 0-9. I also take it that anything other than that will be stripped out? Any other comments? Right. I'd write it as s/[^a-zA-Z0-9]+//g; for efficiency. Or perhaps as tr/a-zA-Z0-9//cd; for clarity. Your ideas of efficiency and clarity may differ. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** stu what does y/// stand for? tenderpuss why, yansliterate of course. -- 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: Confirmation...
Hi Messier, Try that: #[1] $str=206.48.16.3/12345; $str=~ s/\/.*//g; #[2] $str=src=206.48.16.3/12345; $str=~ s/^src=|\/.*//g; I hope that helps. --Ahmed [EMAIL PROTECTED] | http://arbornet.org/~ahmed On Thu, 6 Dec 2001, Messier, Jean-Francois wrote: I'm a beginner in those regular expressions and s/// operations. How can I extract only the digits and the periods (.) from a string ? I have something like 206.48.16.3/12345. An IP address with a port number. There are digits on both sides of the slash, but I would like to keep only the digits from on the left as well as the periods. More complex question: If I have something like src=206.48.16.3/12345, how can I do the same as bove, but also removing the src= at the beginning ? Thanks :-) Jean-Francois Messier Ottawa, CANADA -Original Message- From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 05, 2001 11:18 PM To: Daniel Falkenberg Cc: [EMAIL PROTECTED] Subject: Re: Confirmation... On Dec 6, Daniel Falkenberg said: $string =~ s/[^a-zA-Z0-9]//g; I take it only allows $string to eq anthing in the charcter class of a-z, A-Z and 0-9. I also take it that anything other than that will be stripped out? Any other comments? Right. I'd write it as s/[^a-zA-Z0-9]+//g; for efficiency. Or perhaps as tr/a-zA-Z0-9//cd; for clarity. Your ideas of efficiency and clarity may differ. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** stu what does y/// stand for? tenderpuss why, yansliterate of course. -- 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: Confirmation...
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Jean-Francois Messier) wrote: I'm a beginner in those regular expressions and s/// operations. How can I extract only the digits and the periods (.) from a string ? I have something like 206.48.16.3/12345. An IP address with a port number. There are digits on both sides of the slash, but I would like to keep only the digits from on the left as well as the periods. More complex question: If I have something like src=206.48.16.3/12345, how can I do the same as bove, but also removing the src= at the beginning ? my $ip = src=206.48.16.3/12345; $ip =~ s{^src=|/\d+$}{}g; print $ip; -- brian d foy [EMAIL PROTECTED] - Perl services for hire CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Confirmation...
- Original Message - From: Messier, Jean-Francois [EMAIL PROTECTED] To: [EMAIL PROTECTED]; Daniel Falkenberg [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, December 07, 2001 12:06 AM Subject: RE: Confirmation... I'm a beginner in those regular expressions and s/// operations. How can I extract only the digits and the periods (.) from a string ? I have something like 206.48.16.3/12345. An IP address with a port number. There are digits on both sides of the slash, but I would like to keep only the digits from on the left as well as the periods. More complex question: If I have something like src=206.48.16.3/12345, how can I do the same as bove, but also removing the src= at the beginning ? This /([\d.]*)\/.*/g works irregardless whether your ip is 206.48.16.3/12345 or src=206.48.16.3/12345 $ip = 'src=206.48.16.3/12345'; $ip =~/([\d.]*)\/.*/g; print $1; $ip = '206.48.16.3/12345' ; $ip =~/([\d.]*)\/.*/g; print $1; _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Confirmation...
List, Just a quick question of confirmation as to what the following REs does... $string =~ s/[^a-zA-Z0-9]//g; I take it only allows $string to eq anthing in the charcter class of a-z, A-Z and 0-9. I also take it that anything other than that will be stripped out? Any other comments? Regards, Dan == VINTEK CONSULTING PTY LTD (ACN 088 825 209) Email: [EMAIL PROTECTED] WWW:http://www.vintek.net Tel:(08) 8523 5035 Fax:(08) 8523 2104 Snail: P.O. Box 312 Gawler SA 5118 == -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Confirmation...
On Dec 6, Daniel Falkenberg said: $string =~ s/[^a-zA-Z0-9]//g; I take it only allows $string to eq anthing in the charcter class of a-z, A-Z and 0-9. I also take it that anything other than that will be stripped out? Any other comments? Right. I'd write it as s/[^a-zA-Z0-9]+//g; for efficiency. Or perhaps as tr/a-zA-Z0-9//cd; for clarity. Your ideas of efficiency and clarity may differ. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** stu what does y/// stand for? tenderpuss why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Confirmation... but, what if....
List, What if $string does not meet the criteria in s/[^a-zA-Z0-9]+//g; can I get a print statement to say... if ($string ne s/[^a-zA-Z0-9]+//g) { print $string does not meet our criteria...! Please try another password\n; } Is this OK Dan -Original Message- From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]] Sent: Thursday, 6 December 2001 2:48 PM To: Daniel Falkenberg Cc: [EMAIL PROTECTED] Subject: Re: Confirmation... On Dec 6, Daniel Falkenberg said: $string =~ s/[^a-zA-Z0-9]//g; I take it only allows $string to eq anthing in the charcter class of a-z, A-Z and 0-9. I also take it that anything other than that will be stripped out? Any other comments? Right. I'd write it as s/[^a-zA-Z0-9]+//g; for efficiency. Or perhaps as tr/a-zA-Z0-9//cd; for clarity. Your ideas of efficiency and clarity may differ. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** stu what does y/// stand for? tenderpuss why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Confirmation... but, what if....
On Dec 6, Daniel Falkenberg said: What if $string does not meet the criteria in s/[^a-zA-Z0-9]+//g; can I get a print statement to say... if ($string ne s/[^a-zA-Z0-9]+//g) { print $string does not meet our criteria...! Please try another password\n; } You mean, how can I see if a string contains invalid characters? This is an exercise from my book (chapter 2, Simple Pattern Elements): == 8. Write a simple function that determines if the value given to it is a valid hexadecimal number. Hexadecimal numbers have digits from 0 to 9, and then from A to F (in upper- or lower-case). Does your function accept the empty string has a hexadecimal number? If so, fix it so that it does not. == And here is the solution given: == 8. Here's the first approach, which ends up matching the empty string: # if $num does NOT contain a # character other than a-f, 0-9 # it is an OK hex number if ($num !~ /[^a-f0-9]/i) { ... } The reason that accepts an empty string is because an empty string doesn't contain a character outside of the required character set. That being said, there are many ways to make sure our string is not empty: # here, ... represents our regex from above # check for length if (length($num) and ...) { ok } # check against '' if ($num ne '' and ...) { ok } # match a valid character if ($num =~ /[a-f0-9]/i and ...) { ok } == I trust you can extrapolate that to your case. You want to make sure a string contains ONLY the characters [A-Za-z0-9]. So use that in these code examples instead of the hexadecimal class, [a-fA-F0-9]. You might notice I've used [a-f0-9] in these examples -- that's because I have the /i modifier on, which means the regex is case-insensitive. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for Regular Expressions in Perl published by Manning, in 2002 ** stu what does y/// stand for? tenderpuss why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]