note 96117 deleted from features.commandline by danbrown
| From: | danbrown@php.net | Date: | Thu, 03 Mar 2011 19:16:59 +0000 |
| Subject: | note 96117 deleted from features.commandline by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-177542@lists.php.net to get a copy of this message | ||
Note Submitter: Reinhard at Neidl dot net
----
To place a php-script in a pipe you can use:
xargs -d "\n" ./mysrcipt.php --foo
With many lines/args the ./myscript.php will be called a couple times, but always with --foo.
e.g.:
./myscript.php:
#!/bin/php
<?php
foreach($args as $key => $value){
echo "\n".$key.":".$value;
}
?>
cat -n1000 /path/file | xargs -d "\n" ./myscript.php --foo | less
will call the script two times with echo to stdout/less:
0:./myscript
1:--foo
2:[file-line1]
3:[file-line2]
...
800:[file-line799]
0:./myscript
1:--foo
2:[file-line800]
...