RE: [PHP] Regular Expressions? Help!

From: Date: Mon, 25 Mar 2002 20:49:42 +0000
Subject: RE: [PHP] Regular Expressions? Help!
Groups: php.general 
Request: Send a blank email to php-general+get-90089@lists.php.net to get a copy of this message
exec() works for me. Remember, though, it returns only the LAST line. Have you tried the following to ensure it's constructing the command you think it is: $mycmd = "$prog $cmdline $trimline &"; print $mycmd; $output = exec($mycmd); -----Original Message----- From: Walker, Roy [mailto:Roy.Walker@GEZWM.com] Sent: Monday, March 25, 2002 2:27 PM To: 'Rick Emery'; 'php-general@lists.php.net' Subject: RE: [PHP] Regular Expressions? Help! Perhaps it is how I am calling the $lines in a while loop.? I have tried $cmd, exec(), exec($cmd, $ouput) (to capture the output as an array), system(), shell_exec(). None of them let me capture the STDOUT from the program. There has to be a way to do this. Anyone? Thanx -----Original Message----- From: Rick Emery [mailto:remery@excel.com] Sent: Monday, March 25, 2002 2:07 PM To: 'Walker, Roy'; 'php-general@lists.php.net' Subject: RE: [PHP] Regular Expressions? Help! exec() -----Original Message----- From: Walker, Roy [mailto:Roy.Walker@GEZWM.com] Sent: Monday, March 25, 2002 2:05 PM To: 'php-general@lists.php.net' Subject: RE: [PHP] Regular Expressions? Help! I just realized why nothing I was trying for the regular expressions wasn't working. The command I am running is a C program on the command line of a Linux box. I can't capture the output, it just gets output onto the screen. I just echo'd $output after the command was run and it was empty. Any ideas? -----Original Message----- From: Rick Emery [mailto:remery@excel.com] Sent: Monday, March 25, 2002 1:54 PM To: 'Walker, Roy' Subject: RE: [PHP] Regular Expressions? Help! well, ya might try: $my_array = explode( "\" ",$output); this would set: $my_vars[0] = "variable1:\"some text info\"" $my_vars[1] = "variable2:\"some text info\"" then, you can do an explode on each of the my_vars another, which might work: <?php $output = "variable1:\"some information\" variable2:\"some information\""; ereg( "(variable[0-9]*):\"(.*)\" (variable[0-9]*):\"(.*)\"", $output, $regs); print "output = $output\n"; print $regs[0]." - 0\n"; print $regs[1]." - 1\n"; print $regs[2]." - 2\n"; print $regs[3]." - 3\n"; print $regs[4]." - 4\n"; ?> WHEN EXECUTED DISPLAYS THIS: C:\>php -q zz.php\ output = variable1:"some information" variable2:"some information" variable1:"some information" variable2:"some information" - 0 variable1 - 1 some information - 2 variable2 - 3 some information - 4 -----Original Message----- From: Walker, Roy [mailto:Roy.Walker@GEZWM.com] Sent: Monday, March 25, 2002 1:31 PM To: 'Rick Emery' Subject: RE: [PHP] Regular Expressions? Help! There will be a specific number of variables returned. I just wanted to set all the output to a string and just run through it to grab the variables. Thanx -----Original Message----- From: Rick Emery [mailto:remery@excel.com] Sent: Monday, March 25, 2002 1:28 PM To: 'Walker, Roy'; 'php-general@lists.php.net' Subject: RE: [PHP] Regular Expressions? Help! With there be a specifc number of variables returne? Or can the number of variables vary? -----Original Message----- From: Walker, Roy [mailto:Roy.Walker@GEZWM.com] Sent: Monday, March 25, 2002 1:26 PM To: 'php-general@lists.php.net' Subject: [PHP] Regular Expressions? Help! I am trying to do a match for an expression and it to a variable from the output of a command: <?php $lines = file ($file); while (list ($line_num, $line) = each ($lines)) { $trimline = trim ($line); $output = shell_exec ("$prog $cmdline $trimline &"); } ?> How can look through $output to set the information returned as different variables the output would look like: variable1:"some information" variable2:"some information" I want to set each variable to a string and write it to a file. Thank You for you help. Roy ************************** PLEASE NOTE ************************** This E-Mail/telefax message and any documents accompanying this transmission may contain privileged and/or confidential information and is intended solely for the addressee(s) named above. If you are not the intended addressee/recipient, you are hereby notified that any use of, disclosure, copying, distribution, or reliance on the contents of this E-Mail/telefax information is strictly prohibited and may result in legal action against you. Please reply to the sender advising of the error in transmission and immediately delete/destroy the message and any accompanying documents. Thank you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ************************** PLEASE NOTE ************************** This E-Mail/telefax message and any documents accompanying this transmission may contain privileged and/or confidential information and is intended solely for the addressee(s) named above. If you are not the intended addressee/recipient, you are hereby notified that any use of, disclosure, copying, distribution, or reliance on the contents of this E-Mail/telefax information is strictly prohibited and may result in legal action against you. Please reply to the sender advising of the error in transmission and immediately delete/destroy the message and any accompanying documents. Thank you. ************************** PLEASE NOTE ************************** This E-Mail/telefax message and any documents accompanying this transmission may contain privileged and/or confidential information and is intended solely for the addressee(s) named above. If you are not the intended addressee/recipient, you are hereby notified that any use of, disclosure, copying, distribution, or reliance on the contents of this E-Mail/telefax information is strictly prohibited and may result in legal action against you. Please reply to the sender advising of the error in transmission and immediately delete/destroy the message and any accompanying documents. Thank you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ************************** PLEASE NOTE ************************** This E-Mail/telefax message and any documents accompanying this transmission may contain privileged and/or confidential information and is intended solely for the addressee(s) named above. If you are not the intended addressee/recipient, you are hereby notified that any use of, disclosure, copying, distribution, or reliance on the contents of this E-Mail/telefax information is strictly prohibited and may result in legal action against you. Please reply to the sender advising of the error in transmission and immediately delete/destroy the message and any accompanying documents. Thank you.

« previous php.general (#90089) next »