Re: grab the complete commandline used ...
| From: | Robert Cummings | Date: | Fri, 29 Aug 2008 19:41:10 +0000 |
| Subject: | Re: grab the complete commandline used ... | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-279009@lists.php.net to get a copy of this message | ||
On Fri, 2008-08-29 at 15:36 -0400, Robert Cummings wrote:
> On Fri, 2008-08-29 at 20:42 +0200, Jochem Maas wrote:
> > Robert Cummings schreef:
> > > On Fri, 2008-08-29 at 04:48 +0200, Jochem Maas wrote:
> > >> Micah Gersten schreef:
> > >>> I suggest creating a shell wrapper for PHP that will write the command
> > >>> to a file for you and then call PHP with the appropriate arguments. PHP
> > >>> won't even see most of the command that you originally posted.
> > >> which wouldn't catch the pipe to grep now would it. nevermind, I don't
> > >> think
> > >> you ge what I was looking for, not worry I can hack together a
> > >> 'solution'
> > >> using exec() ... by grepping the output of ps.
> > >
> > > I doubt it. The ps command sees what the script sees. If I do mplayer
> > > *.avi, ps shows me the expanded file list that was given to mplayer.
> >
> > output after shell expansion is fine, I'm interested in knowing what
> > arguments we're given to the php interpreter, for example
> > (other than the scriptname and *it's* args which are readily available
> > via $argv) and where ever the output is being piped or redirected to.
>
> You won't get redirection or piping from the following but it will give
> you the command line info you wanted:
>
> <?php
>
> $info = implode( '', file( '/proc/'.posix_getpid().'/cmdline' )
> );
> $info = explode( "\x0", $info );
> print_r( $info );
>
> ?>
>
> Probably doesn't run on windows, and I don't care enough to even think
> about checking :)
BTW, you can also look into hacking the bash binary. Several years ago I
wanted to log the command-line to a database table and I hacked the bash
binary to trap history and send to database log.
Isn't open source a beautiful thing :)
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP