[PHP] PHP passthru() blocks with bash process replacement?

2012-03-05 Thread Sander Marechal
Hi all,

I have a problem with PHP passthru() blocking when it is supposed to start a
daemon and return.

I have a Node.js daemon with a bash script wrapper around it. Users can call
this bash script directly, but it is also used by our deployment system. Our
deployment system uses Phing, and Phing uses `exec()` and `passthru()`
internally to cann external programs.


The bash script wrapper around my Node.js uses a bit of process replacement
because my Node.js server can't directly log to syslog. Normally I'd start
Node.js like this:

forever -l app.log app.js

But because I want it to log to syslog, I put this in the bash script:

forever -l (logger) app.js

The `logger` process replacement creates a file descriptor into syslog like
/dev/fd/63 whose path is passed to the forever command as the logfile to use.

This works great when I start the daemon using the bash script directly, but
when the bash script is executed using PHP passthru() or exec() then these
calls will block. If I use a regular logfile instead of the process
replacement then both passthru() and exec() work just fine, starting the
daemon in the background.

I have created a complete working example (using a simple PHP daemon instead
of Node.js) on Github's Gist: https://gist.github.com/1977896 (needs PHP 5.3.6+)

Why does the passthru() call block on the process replacement? And is there
anything I can do to work around it?

Kind regards,

-- 
Sander Marechal

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] passthru

2007-08-07 Thread Richard Lynch
On Mon, August 6, 2007 4:14 am, Payne wrote:
 Does anyone know way to passthru man pages so they don't show the
 ascii
 formating?

The man command itself has a man page which describes how to format
the output to your liking, with or without all kinds of formatting.

man man

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] passthru

2007-08-06 Thread Payne

Hi,

Does anyone know way to passthru man pages so they don't show the ascii 
formating?


Payne

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] passthru

2007-08-06 Thread Richard Heyes
Does anyone know way to passthru man pages so they don't show the ascii 
formating?


You could:

1) Replace all newlines (ASCII 10) with a br tag. htmlspecialchars()
   will do this for you.
2) Use a pre tag within which newlines are preserved
3) Use preg_replace to replace non-printable characters (Can't remember
   how exactly, but everything you need is in the manual - you will want
   to strip everything from ASCII 1 - ASCII 32. IIRC.

--
Richard Heyes
+44 (0)844 801 1072
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] passthru

2007-08-06 Thread Payne

Richard Heyes wrote:
Does anyone know way to passthru man pages so they don't show the 
ascii formating?


You could:

1) Replace all newlines (ASCII 10) with a br tag. htmlspecialchars()
   will do this for you.
2) Use a pre tag within which newlines are preserved
3) Use preg_replace to replace non-printable characters (Can't remember
   how exactly, but everything you need is in the manual - you will want
   to strip everything from ASCII 1 - ASCII 32. IIRC.


Thanks, I will give that a shot.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] passthru

2007-08-06 Thread POLONKAI Gergely
Why don't you just use the man2html script?

2007. 08. 6, hétfő keltezéssel 05.14-kor Payne ezt írta:

 Hi,
 
 Does anyone know way to passthru man pages so they don't show the ascii 
 formating?
 
 Payne
 


Re: [PHP] passthru() passing variables

2005-06-18 Thread Richard Lynch
On Fri, June 17, 2005 6:47 am, Jason Barnett said:
 What is a reliable cross-platform way of showing which user PHP is
 running as?

http://php.net/get_current_user

The bogus User Contributed note about REMOTE_USER is, well, bogus, almost
for sure.

If that fails, I guess you could try:

?php
  ob_start();
  phpinfo();
  $phpinfo = ob_endclean();
?

Then you have to dig out the PHP User from that.

It's possible there is a PHP Constant here that is the User:
http://php.net/manual/en/language.constants.predefined.php

If none of those work, I'm guessing even Windoze has something like
whoami so you could http://php.net/exec whoami or its equivalent,
based on the http://php.net/php_sapi_name

If all that fails, I'd just give up. :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] passthru() passing variables

2005-06-17 Thread Jason Barnett
What is a reliable cross-platform way of showing which user PHP is 
running as?


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] passthru() passing variables

2005-06-16 Thread Richard Lynch
On Thu, June 16, 2005 11:44 am, Chris Herold said:
 Thanks for the tips;  however, I think I am still missing something.

 My perl script is running when called by passthru() because within the
 body of the simple test code I have set it up to:

 code
 print Content-type: text/html\n\n;

 print Source ID: $source_id;
 /code

 and when I run the php with the full address to my file (abbreviated
 here and before for brevity):


 $source_id = test;
 passthru(/home/.../cgi-bin/passthru_test.cgi $source_id);


 it prints out

 Content-type: text/html Source ID:

 Which is what I expect although missing the printout for the source_id
 value.

Is Perl set with that Tainted mode thing where it won't *LET* you use
arguments from the outside world unless you at least pretend to scrub
them?

To test, what happens when you run text.cgi test from the command line
without PHP in the picture?

 Re:Exec()

 I have tried exec and it does not seem to be working for me in terms of
 producing an error output.

 I set it up for:

 exec(/home/httpd/vhosts/omniomix.com/cgi-bin/passthru_test.cgi
 $source_id,$out,$err);

 and I get no printout at all.

 Is there something obvious that I am doing wrong?

exec won't print anything at all.

You have to take further action to print out $out and/or $err.

Also, move the quote at the end of $err to be after $source_id

As it is now, you are passing 2 more arguments with commas to your
Perl/cgi script, not  providing 2 more arguments to exec.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] passthru() passing variables

2005-06-16 Thread Richard Lynch
I dunno what 127 actually means, but the last time we saw it on this list,
it boiled down to:

You can't even run your 'sh' shell, much less Perl in that shell.

Check what's in /bin/sh and what its permissions are.

Make sure it's actually a valid shell binary, and not something bogus.

If that's not it, keep digging.

Somewhere, somehow, you've got something in permissions that is not
allowing you to run a process/binary you need.

If it's not /bin/sh, look at Perl.
If it's not Perl, check your permissions on test.cgi again.

Remember that PHP does not run as you with all your permissions - If you
can 'su' to the user PHP runs as, this could get a lot easier to test...

Check httpd.conf User directive to be certain you know what user PHP
runs as, or check ?php phpinfo()? output.

On Thu, June 16, 2005 11:55 am, Chris Herold said:
 I'm sorry, when I do the exec() */properly/ *I get

 OS Error: 127
 Content-type: text/html

 Source ID:

 Richard Lynch wrote:

On Wed, June 15, 2005 5:36 pm, Chris Herold said:


I have been told that in order to pass variables via passthru() to
another script (in my case, a perl script) one can do the following ...

passthru(home/test.cgi $var)

and that $var will then be passed through to the cgi.

I have tried this and failed.

Is this the proper format or is there something that I am missing.



You may want to use exec first, so you can more easily capture the error
output and error codes.

exec(home/test.cgi $var, $output, $error);
if ($error){
  //You should probably use error_log here in your real code...
  //ASSUME this is going to break some day, for whatever reason.
  //You'll need it logged unless you like dealing with error reports
 like:
  //Hey, the website broke yesterday.
  echo OS Error:  $errorbr /\n;
  echo implode(br /, $output);
  exit;
}
echo $output;

Meanwhile, odds are *REALLY* good that you're not even calling the
test.cgi script because you haven't provide a path that PHP can use.

home/test.cgi would be assuming that home was in the same directory as
your PHP script, and even that is kinda iffy depending on where you do
this from the webserver or CLI...

I would recommend using FULL PATH to *everything* in exec (and passthru)

/full/path/to/home/test.cgi /full/path/to/any/args.txt

Also be sure to use the escapeshellargs function to make your $var data
kosher if it comes from the outside world.






-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] passthru() passing variables

2005-06-15 Thread Chris Herold

Hi,

I have been told that in order to pass variables via passthru() to 
another script (in my case, a perl script) one can do the following ...


passthru(home/test.cgi $var)

and that $var will then be passed through to the cgi.

I have tried this and failed.

Is this the proper format or is there something that I am missing.

Thanks,
chris

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] passthru() passing variables

2005-06-15 Thread Richard Lynch
On Wed, June 15, 2005 5:36 pm, Chris Herold said:
 I have been told that in order to pass variables via passthru() to
 another script (in my case, a perl script) one can do the following ...

 passthru(home/test.cgi $var)

 and that $var will then be passed through to the cgi.

 I have tried this and failed.

 Is this the proper format or is there something that I am missing.

You may want to use exec first, so you can more easily capture the error
output and error codes.

exec(home/test.cgi $var, $output, $error);
if ($error){
  //You should probably use error_log here in your real code...
  //ASSUME this is going to break some day, for whatever reason.
  //You'll need it logged unless you like dealing with error reports like:
  //Hey, the website broke yesterday.
  echo OS Error:  $errorbr /\n;
  echo implode(br /, $output);
  exit;
}
echo $output;

Meanwhile, odds are *REALLY* good that you're not even calling the
test.cgi script because you haven't provide a path that PHP can use.

home/test.cgi would be assuming that home was in the same directory as
your PHP script, and even that is kinda iffy depending on where you do
this from the webserver or CLI...

I would recommend using FULL PATH to *everything* in exec (and passthru)

/full/path/to/home/test.cgi /full/path/to/any/args.txt

Also be sure to use the escapeshellargs function to make your $var data
kosher if it comes from the outside world.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] passthru in IE: fullscreen display of SWF

2005-05-26 Thread dc

hi list-
(B
(BI am trying to display a SWF file fullscreen, but having problems with IE.
(B
(BThis is a SWF file that is sitting on the disc, and i want to do a simple  
(Bpassthru; works fine in opera, firefox, but not IE. Found some notes on  
(Bthis issue, realted to downloads, but not to full-screen display.

(B
(BAlso, do not see the same problems when doing dev from .net; so it is a  
(BPHP  IE thing.

(B
(BI found a "content-disposition: inline" tip, but did not work.
(B
(BCode snip below
(B
(B
(Bfunction pass4($name) {
(B
(B // specify the REAL path for your file and not the URL
(B $path = getcwd()."./".$name;
(B
(B // "inline" to view file in browser
(B // or "attachment" to download to hard disk
(B $disposition = "inline";
(B
(B $mime = "application/x-shockwave-flash";
(B 
(B if (! $fd = fopen ($path, "rb")) {
(B die ("couldnt open $path");
(B } else {
(B $fsize=filesize($path);
(B // $fname= basename ($path);
(B
(B header("Cache-Control: no-cache, must-revalidate");
(B header("Pragma: no-cache");
(B header("Content-Type: $mime");
(B		header("Content-Disposition:$disposition;  
(Bfilename=\"".trim(htmlentities($name))."\"");

(B header("Content-Description: ".trim(htmlentities($name)));
(B header("Content-Length: ".(string)(filesize($path)));
(B header("Connection: close");
(B
(B fpassthru($fd);
(B }
(B}
(B
(B
(B-- 
(B___

(BDavid "DC" Collier
(Bmobile business creator $B!C%b%P%$%k!&%S%8%M%9!&%/%j%(!<%?!<(B
(B
(B-- 
(BPHP General Mailing List (http://www.php.net/)

(BTo unsubscribe, visit: http://www.php.net/unsub.php


[PHP] passthru and GET parameters

2004-02-23 Thread Guillouet Nicolas
Hi all,

I am trying to use htmldoc with passthru function : 

passthru(htmldoc -t html --quiet --jpeg --webpage --footer --bottom
0.2cm --left 1.78cm --right 1cm --top 0.2cm '' $options $filename);

where $filename is urls, it works fine but not with GET pamameters :
 if $filename is like
'http://host/file.php?PHPSESSID=**value=1', passthru is
waiting for the command.

I think the trouble comes from the char '', I have the same result on
command line except if I use quote for the filename. And when I watch
the process created by apache, the command is send without quote or
quotation mark even if I put some in the filename.

How can I do ?

Thanks 

Nicolas

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] passthru and GET parameters

2004-02-23 Thread Marek Kilimajer
put quotes around:

passthru(htmldoc -t html --quiet --jpeg --webpage --footer --bottom
 0.2cm --left 1.78cm --right 1cm --top 0.2cm '' $options '$filename');
Guillouet Nicolas wrote:
Hi all,

I am trying to use htmldoc with passthru function : 

passthru(htmldoc -t html --quiet --jpeg --webpage --footer --bottom
0.2cm --left 1.78cm --right 1cm --top 0.2cm '' $options $filename);
where $filename is urls, it works fine but not with GET pamameters :
 if $filename is like
'http://host/file.php?PHPSESSID=**value=1', passthru is
waiting for the command.
I think the trouble comes from the char '', I have the same result on
command line except if I use quote for the filename. And when I watch
the process created by apache, the command is send without quote or
quotation mark even if I put some in the filename.
How can I do ?

Thanks 

Nicolas

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Passthru with Grep and Awk?

2004-01-15 Thread Carlton L. Whitmore
I'm having problems getting the following passthru statement to work. It
works fine with the just the grep command.
Help  
 
?php
echo pre\n;
passthru('/usr/bin/grep  c=2048  c=32  c=2 /var/log/messages |
/usr/bin/awk {print $1 $3 $5} ');
?



Re: [PHP] Passthru with Grep and Awk?

2004-01-15 Thread Jason Wong
On Friday 16 January 2004 06:06, Carlton L. Whitmore wrote:
 I'm having problems getting the following passthru statement to work. It
 works fine with the just the grep command.
 Help

 ?php
 echo pre\n;
 passthru('/usr/bin/grep  c=2048  c=32  c=2 /var/log/messages |
 /usr/bin/awk {print $1 $3 $5} ');
 ?

1) Is

grep  c=2048  c=32  c=2 /var/log/messages

a valid command? My version of grep only allows a single search pattern.

2) Do you have the necessary permissions to access '/var/log/messages' ?

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
I know not how I came into this, shall I call it a dying life or a
living death?
-- St. Augustine
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Passthru with Grep and Awk?

2004-01-15 Thread Brian V Bonini
On Thu, 2004-01-15 at 17:06, Carlton L. Whitmore wrote:
 I'm having problems getting the following passthru statement to work. It
 works fine with the just the grep command.
 Help  
  
 ?php
 echo pre\n;
 passthru('/usr/bin/grep  c=2048  c=32  c=2 /var/log/messages |
 /usr/bin/awk {print $1 $3 $5} ');
 ?

That's not going to do what your thinking it will. Use egrep instead.

$ egrep 'c-2048 | c=32 | c=2' /var/log/messages

However you can do what you want with just awk, no need to involve
(e)grep.

$ cat /var/log/messages | awk '/c=2048|c=32|c-2/ {print $1 $3 $5}'



-- 
BrianGnuPG - KeyID: 0x04A4F0DC | URL: www.gfx-design.com/keys
  Key Server: pgp.mit.edu
==
gpg --keyserver pgp.mit.edu --recv-keys 04A4F0DC
GnuPG: http://gnupg.org
http://www.biglumber.com/x/web?qs=0x2C35011004A4F0DC
Linux Registered User #339825 at http://counter.li.org


signature.asc
Description: This is a digitally signed message part


Re: Re[2]: [PHP] passthru gives error in httpd/error_log

2003-11-22 Thread Jesper Hansen
 Then there must be some kind of restriction on the server, Is it running
in
 chrooot enviroment. Try copying ls to a directory in the server root and
try
 again.
 -- 
 regards,
 Tom

I've tried that too, with ls and other programs in the local directory where
the
script was located. And with permissions set to 777. Even on the dir. No go.
Still the same error log message :  sh: /ls: No such file or directory.
Specifying a specific path will give, for instance :
sh: /bin/ls: No such file or directory.

This seems impossible, as the file is clearly there, but I can't find any
more
info on this message.

/Jesper

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] passthru gives error in httpd/error_log

2003-11-22 Thread Jason Wong
On Friday 21 November 2003 08:53, Jesper Hansen wrote:

 I'm trying to run a super simple command through passthru.

 Here's my test.php file:

 htmlbody
 ? passthru('ls -l'); ?
 /body/html


 It works if run directly with php test.php.
 When this is run from the browser, there is no output, and the
 following error is logged in /var/log/httpd/error_log :
 sh: /ls: No such file or directory

What does the php error log say?

 What does this mean ? Any command I try instead of ls -l,
 gives a similar error.

 The funky thing is that it HAS worked, but now it doesn't, and
 I have no idea what happened.

Find out what funky thing it was that you did to make it stop working.

Are you using safe mode and is safe_mode_exec_dir set appropriately?

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz

/*
What is research but a blind date with knowledge?
-- Will Harvey
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] passthru gives error in httpd/error_log

2003-11-21 Thread Jesper Hansen
Tom Rogers [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 You probably have to put the full path to ls

 ? passthru('/bin/ls -l'); ?
 -- 
 regards,
 Tom

No, I've tried that along with all other obvious path stuff.

/Jesper

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re[2]: [PHP] passthru gives error in httpd/error_log

2003-11-21 Thread Tom Rogers
Hi,

Saturday, November 22, 2003, 1:23:36 AM, you wrote:
JH Tom Rogers [EMAIL PROTECTED] wrote in message
JH news:[EMAIL PROTECTED]
JH No, I've tried that along with all other obvious path stuff.

JH /Jesper

Then there must be some kind of restriction on the server, Is it running in
chrooot enviroment. Try copying ls to a directory in the server root and try
again.
-- 
regards,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] passthru gives error in httpd/error_log

2003-11-20 Thread Jesper Hansen
I'm trying to run a super simple command through passthru.

Here's my test.php file:

htmlbody
? passthru('ls -l'); ?
/body/html


It works if run directly with php test.php.
When this is run from the browser, there is no output, and the
following error is logged in /var/log/httpd/error_log :
sh: /ls: No such file or directory

What does this mean ? Any command I try instead of ls -l,
gives a similar error.

The funky thing is that it HAS worked, but now it doesn't, and
I have no idea what happened.

Any clues and hints are much appreciated.

/Jesper

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] passthru gives error in httpd/error_log

2003-11-20 Thread Tom Rogers
Hi,

Friday, November 21, 2003, 10:53:08 AM, you wrote:
JH I'm trying to run a super simple command through passthru.

JH Here's my test.php file:

JH htmlbody
JH ? passthru('ls -l'); ?
JH /body/html


JH It works if run directly with php test.php.
JH When this is run from the browser, there is no output, and the
JH following error is logged in /var/log/httpd/error_log :
JH sh: /ls: No such file or directory

JH What does this mean ? Any command I try instead of ls -l,
JH gives a similar error.

JH The funky thing is that it HAS worked, but now it doesn't, and
JH I have no idea what happened.

JH Any clues and hints are much appreciated.

JH /Jesper

You probably have to put the full path to ls

? passthru('/bin/ls -l'); ?

-- 
regards,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] passthru loses php posted variables

2003-09-14 Thread exasperated
Anyone come across something like this before?

I have made a little test script as follows:
?
header (Content-Type: application/pdf);
$command_line = /usr/bin/pdflabelseries  .
escapeshellcmd($_POST['labelstart']) .   .
escapeshellcmd($_POST['labelend']);
exec (echo \$command_line\ /opt/specs/labels.txt);
//passthru($command_line);
?

The form takes input from a posted form with two variables, labelstart and
labelend.  In the above test, if I put in 'start' and 'end' as the posted
variable data, the output from /opt/specs/labels.txt (writable by the http
server) is:
/usr/bin/pdflabelseries start end
All is well and good.  Now is where it heads South.  I uncomment the
passthru command above.  The output from the script in /opt/specs/labels.txt
from the same posted form with the same data entered is now:
/usr/bin/pdflabelseries
pdflabelseries is a C program that I have confirmed works perfectly on the
command line (i.e. generates the requisite pdf file to stdout).
Even if the C program fails (which it does not appear to do from the output
in the httpd logs as it outputs its command line to stderr), surely php
should not lose its own internal variables, especially, for a command that
is executed BEFORE the passthru command.

I am truly baffled.

Any help appreciated.
Regards

Mark

I am running vanilla Mandrake 9.1 with the following PHP rpms:
libphp_common430-430-11mdk
php-pear-4.3.0-3mdk
apache2-mod_php-2.0.44_4.3.1-2mdk
php-xml-4.3.0-2mdk
php-dba_bundle-4.3.0-4mdk
php-pgsql-4.3.0-4mdk
php-xmlrpc-4.3.0-2mdk
php-manual-en-4.3.0-2mdk
php430-devel-430-11mdk
php-gd-4.3.0-2mdk

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] passthru() problem

2003-07-02 Thread david
I'm trying to get the output of a shell command with PHP 

This is the command I'm Trying to execute, I also tried using system instead
of passthru

 

?php

  passthru(ftpwho -v, $return_var);

  echo $return_var;

?

 

Both cases passthru and system Outputed 2 but should have outputted
something like this:

 

standalone FTP daemon [17899]:

21852 geiri[ 4h45m] (n/a) STOR /UPLOAD_HERE/moviemusic/The Soprano's -
Music from the HBO Original Series

KB/s: 143.87

client: client.client.de [12.2.2.3]

server: 62.145.135.125:2121 (shiiit.serbinn.com)

location: /MP3/ Music/

 

Any Idea about what  could be wrong



Re: [PHP] passthru() problem

2003-07-02 Thread Jason Wong
On Wednesday 02 July 2003 22:04, david wrote:
 I'm trying to get the output of a shell command with PHP

 This is the command I'm Trying to execute, I also tried using system
 instead of passthru



 ?php

   passthru(ftpwho -v, $return_var);

   echo $return_var;

 ?

passthru (et al) expects the command argument to be a string.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Dental health is next to mental health.
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] passthru returns with errno 11

2002-12-13 Thread phplist
What could that mean errno 11 when I try to run a small program with four
parameters. From a shell prompt it works. What does it mean errno 11?

--
René
www.comunica2.net



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Passthru / exec question - '127' returned

2002-12-05 Thread Lee P. Reilly
Hi,

I've ran into a problem using the passthru/exec commands with RH8. When
I try and run my program (or even pwd, ls, etc) the number '127' is
returned every_time. With passthru, the size of the optional return
array is 0. Can anyone fathom a guess at the problem? Is the 127 value
signifcant?

Thanks in advance.

- Best regards,

   Lee



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] passthru problems generating WAVs with mpg123

2002-10-26 Thread soren
I've written a little script for VoiceXML applications to generate a WAV 
from an MP3 on demand:

#file wavwrapper.php
?
header('Content-Type: audio/wav');
$filename = $_GET['filename'];

$mp3dir=/var/www/mp3s/;
$playercmd=/usr/local/bin/mpg123 -m -w - -q -4 --8bit;
passthru($playercmd $mp3dir/$filename 2 /tmp/playererror);
?


I request it as wavwrapper?filename=song.mp3, and the browser reads the 
MIME type properly, prompts me to play or download the song.  I download 
it, and save it as a WAV file.  However, Mozilla downloads about 1.5M of 
data, saves it all to a file, and then displays the downloaded size as 
1k.  And then when I try to play it back, it won't play; it's like an 
empty file.  Same thing happens if I try to play it directly.  But if I 
redirect the output of mpg123 from standard out (so it goes across the 
web connection) to a file and then download the file, the file plays 
just fine.  I figure there's something to do with the way PHP dumps back 
the binary data that just isn't working right, but I don't know what it 
is.  Anyone have any ideas?

--
Soren Harward
[EMAIL PROTECTED]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] passthru problems generating WAVs with mpg123

2002-10-26 Thread Justin French
I'm SURE you've got a good reason, but why are you wanting to generate a WAV
on demand?  The loss in file quality occurs going from WAV  MP3, so then
later going back to WAV would only result in a bigger file size, with ZERO
benefit in audio quality.

Just asking :)


Justin


on 26/10/02 4:53 PM, [EMAIL PROTECTED] ([EMAIL PROTECTED]) wrote:

 I've written a little script for VoiceXML applications to generate a WAV
 from an MP3 on demand:
 
 #file wavwrapper.php
 ?
 header('Content-Type: audio/wav');
 $filename = $_GET['filename'];
 
 $mp3dir=/var/www/mp3s/;
 $playercmd=/usr/local/bin/mpg123 -m -w - -q -4 --8bit;
 passthru($playercmd $mp3dir/$filename 2 /tmp/playererror);
 ?
 
 
 I request it as wavwrapper?filename=song.mp3, and the browser reads the
 MIME type properly, prompts me to play or download the song.  I download
 it, and save it as a WAV file.  However, Mozilla downloads about 1.5M of
 data, saves it all to a file, and then displays the downloaded size as
 1k.  And then when I try to play it back, it won't play; it's like an
 empty file.  Same thing happens if I try to play it directly.  But if I
 redirect the output of mpg123 from standard out (so it goes across the
 web connection) to a file and then download the file, the file plays
 just fine.  I figure there's something to do with the way PHP dumps back
 the binary data that just isn't working right, but I don't know what it
 is.  Anyone have any ideas?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] passthru()

2002-05-17 Thread gamin

I have a PHP script that computes the URLs  to files that i need to
download. Is it possible to put  passthru() with wget in a while loop and
donwload multiple files at one time ? Or does passthru() complete the shell
command and then proceed.

Any other suggestions ?

thx in advance

gamin.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] PassThru()

2001-05-09 Thread Michael Roark

how does one pass arguements to PassThru()

ie would the following work

PassThru(/home/bleh/bleh.cgi  bleh.txt);

and if that does work PassThru() sends its output back to the page yes?



[PHP] passthru Problems

2001-04-12 Thread Jason Mowat

Greetings,

I am having a small problem displaying PDF files to my users via passthru.
This is the situation: I have a bunch of PDF files on my server directory.
I show the user a listing of the PDF files they can view, and allow them to
hyperlink click on the PDF they wish to browse.  When the user clicks the
link, I execute a header() and then my passthru on my PDF file.  The code is
essentially:
header("Content-type: application/pdf");
passthru($pdf_file);

Now, my problem is that the title of the HTML window that pops up is of the
URL path.  I want to set the title to something meaningful (like the name of
the PDF file the user is looking at).  But, if I try to print a "TITLEPDF
File/TITLE" after the header, my PDF document does not show up (it shows
the raw encoding of the PDF document).

Does anyone have any suggestions to allow me to show a title on a
header/passthru page?  Is there a better way to do this?

Cheers,
Jason



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] passthru Problems

2001-04-12 Thread Krznaric Michael

I believe there is header called "Content-disposition: filename.pdf" which
is defined in the proper RFC.  And as far as I know some browsers don't
respect it.  Search the list for it, you should find allot of info.

Mike

-Original Message-
From: Jason Mowat [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 12, 2001 12:46 PM
To: [EMAIL PROTECTED]
Subject: [PHP] passthru Problems


Greetings,

I am having a small problem displaying PDF files to my users via passthru.
This is the situation: I have a bunch of PDF files on my server directory.
I show the user a listing of the PDF files they can view, and allow them to
hyperlink click on the PDF they wish to browse.  When the user clicks the
link, I execute a header() and then my passthru on my PDF file.  The code is
essentially:
header("Content-type: application/pdf");
passthru($pdf_file);

Now, my problem is that the title of the HTML window that pops up is of the
URL path.  I want to set the title to something meaningful (like the name of
the PDF file the user is looking at).  But, if I try to print a "TITLEPDF
File/TITLE" after the header, my PDF document does not show up (it shows
the raw encoding of the PDF document).

Does anyone have any suggestions to allow me to show a title on a
header/passthru page?  Is there a better way to do this?

Cheers,
Jason



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] passthru Problems

2001-04-12 Thread Jason Mowat

Greets,

Just to elaborate: I want my user to be able to click on a hyperlink that
points to my PDF file, and have a new window pop up, displaying the contents
of the PDF file in the browser window (without prompting if they should save
the file) as well as set the HTML TITLE tag to the name of the report.

My passthru() function works fine, when I send a header() of PDF first, and
then dump the raw PDF out.  But, I cannot set any HTML properties with tags
(like TITLE); it doesn't show the PDF in PDF format then, it shows it all
raw encoded.

Hope that helps clarifying my wants and needs :-)

Cheers,
Jason


""Jason Mowat"" [EMAIL PROTECTED] wrote in message
9b4lso$2gb$[EMAIL PROTECTED]">news:9b4lso$2gb$[EMAIL PROTECTED]...
 Greetings,

 I am having a small problem displaying PDF files to my users via passthru.
 This is the situation: I have a bunch of PDF files on my server directory.
 I show the user a listing of the PDF files they can view, and allow them
to
 hyperlink click on the PDF they wish to browse.  When the user clicks the
 link, I execute a header() and then my passthru on my PDF file.  The code
is
 essentially:
 header("Content-type: application/pdf");
 passthru($pdf_file);

 Now, my problem is that the title of the HTML window that pops up is of
the
 URL path.  I want to set the title to something meaningful (like the name
of
 the PDF file the user is looking at).  But, if I try to print a
"TITLEPDF
 File/TITLE" after the header, my PDF document does not show up (it shows
 the raw encoding of the PDF document).

 Does anyone have any suggestions to allow me to show a title on a
 header/passthru page?  Is there a better way to do this?

 Cheers,
 Jason



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] passthru Problems

2001-04-12 Thread Morgan Curley

You need to use a frameset to do what you want.
the problem is the browser will only launch the Acrobat control if it 
receives the content type app/pdf, an html page uses the content type 
text/html.

your links should point to another page that outputs something like the 
following based on input of the pdf file path and name
( HTML shamelessly stolen from http://www.php4.net/ :-)
HTML
HEAD
TITLE?php echo $your_title ?/TITLE
FRAMESET rows="100%,*" frameborder="0"framespacing="0" border="0" 
align=CENTER
FRAME SRC="?php echo $your_pdf_file_path ?" Name="pdf" scrolling="auto"
FRAME SRC="empty.htm" Name="invisible" scrolling="no"
/FRAMESET
/HTML

if you are using track_vars and don't have the auto globalizing of form 
elements, use
$HTTP_GET_VARS[ 'your_title']
$HTTP_GET_VARS[ 'your_pdf_file_path ']
or
$HTTP_POST_VARS[ 'your_title']
$HTTP_POST_VARS[ 'your_pdf_file_path ']

depending on your form method


morgan



At 03:20 PM 4/12/2001, you wrote:
Greets,

Just to elaborate: I want my user to be able to click on a hyperlink that
points to my PDF file, and have a new window pop up, displaying the contents
of the PDF file in the browser window (without prompting if they should save
the file) as well as set the HTML TITLE tag to the name of the report.

My passthru() function works fine, when I send a header() of PDF first, and
then dump the raw PDF out.  But, I cannot set any HTML properties with tags
(like TITLE); it doesn't show the PDF in PDF format then, it shows it all
raw encoded.

Hope that helps clarifying my wants and needs :-)

Cheers,
Jason


""Jason Mowat"" [EMAIL PROTECTED] wrote in message
9b4lso$2gb$[EMAIL PROTECTED]">news:9b4lso$2gb$[EMAIL PROTECTED]...
  Greetings,
 
  I am having a small problem displaying PDF files to my users via passthru.
  This is the situation: I have a bunch of PDF files on my server directory.
  I show the user a listing of the PDF files they can view, and allow them
to
  hyperlink click on the PDF they wish to browse.  When the user clicks the
  link, I execute a header() and then my passthru on my PDF file.  The code
is
  essentially:
  header("Content-type: application/pdf");
  passthru($pdf_file);
 
  Now, my problem is that the title of the HTML window that pops up is of
the
  URL path.  I want to set the title to something meaningful (like the name
of
  the PDF file the user is looking at).  But, if I try to print a
"TITLEPDF
  File/TITLE" after the header, my PDF document does not show up (it shows
  the raw encoding of the PDF document).
 
  Does anyone have any suggestions to allow me to show a title on a
  header/passthru page?  Is there a better way to do this?
 
  Cheers,
  Jason
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]
 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



[PHP] passthru

2001-04-11 Thread Michael Dickson

On the server itself (to which I have root access) I type:

   someProgram arg1 arg2 arg3

and it runs properly, returning the proper output to standard output (the
screen).  I can do this from anywhere on the server (for example, from the
same directory where my php scripts are located, /var/www/html/blah), and I
can do it as the same user that apache runs as ('apache').

BUT, when I try:

?php passthru("someProgram arg1 arg2 arg3"); ?

it fails.  I get no output at all.  I can check that everything else is ok
by doing something like

?php passthru("someProgram arg1 arg2 arg3"); passthru("echo 'finished'");
?

which then returns just the word 'finished' to the browser.

I CAN do other things via passthru, for example,

?php passthru("man tar"); ?, and

?php passthru("ls -al"); ?

and so on.  I am running php as an apache module.  I am NOT running php in
'safe mode'.

Any ideas what is going wrong here?

Thanks,

Michael Dickson


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] passthru

2001-04-11 Thread Johnson, Kirk

Just guessing here. On our setup, PHP runs as nobody. Is there a permissions
problem around "someProgram"?

Kirk

 -Original Message-
 From: Michael Dickson [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, April 11, 2001 1:27 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] passthru
 
 
 On the server itself (to which I have root access) I type:
 
someProgram arg1 arg2 arg3
 
 and it runs properly, returning the proper output to standard 
 output (the
 screen).  I can do this from anywhere on the server (for 
 example, from the
 same directory where my php scripts are located, 
 /var/www/html/blah), and I
 can do it as the same user that apache runs as ('apache').
 
 BUT, when I try:
 
 ?php passthru("someProgram arg1 arg2 arg3"); ?
 
 it fails.  I get no output at all.  I can check that 
 everything else is ok
 by doing something like
 
 ?php passthru("someProgram arg1 arg2 arg3"); passthru("echo 
 'finished'");
 ?
 
 which then returns just the word 'finished' to the browser.
 
 I CAN do other things via passthru, for example,
 
 ?php passthru("man tar"); ?, and
 
 ?php passthru("ls -al"); ?
 
 and so on.  I am running php as an apache module.  I am NOT 
 running php in
 'safe mode'.
 
 Any ideas what is going wrong here?
 
 Thanks,
 
 Michael Dickson

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] passthru

2001-04-11 Thread Dean Hall

"Michael Dickson" [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On the server itself (to which I have root access) I type:

someProgram arg1 arg2 arg3

 and it runs properly, returning the proper output to standard output (the
 screen).  I can do this from anywhere on the server (for example, from the
 same directory where my php scripts are located, /var/www/html/blah), and
I
 can do it as the same user that apache runs as ('apache').

 BUT, when I try:

 ?php passthru("someProgram arg1 arg2 arg3"); ?

 it fails.  I get no output at all.

I'm just guessing since I can't access the PHP manual and since I don't know
what program you're running here -- but perhaps "someProgram" is outputting
to stderr by mistake. That's my only guess.

Dean Hall.
http://hall.apt7.com



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Passthru Question

2001-03-21 Thread Michael Bartlett

Hi all,

Having a weird problem running the passthru() function on quite an old
version of PHP3 (3.0.7).
Pasted below is the php source code:

===
HTML
HEAD
TITLETape Status Check/TITLE
/HEAD
BODY
if this page is blank - that is good!

?

passthru ('/usr/bin/mt rewind',$res);
echo $res;
?
===

When I run this in a shell (as the apache user as well!) it works perfectly
as illustrated below:

===
su-2.03$ /usr/local/bin/php index.php3
Content-type: text/html


HTML
HEAD
TITLETape Status Check/TITLE
/HEAD
BODY
if this page is blank - that is good!

mt: /dev/nrsa0: Device not configured
===

When I run this in apache by accessing the URL, I get (pasted HTML from
view-source):

===
HTML
HEAD
TITLETape Status Check/TITLE
/HEAD
BODY
if this page is blank - that is good!

1
===

As you can see, its not outputting the passthru output stuff. Any ideas?

Mike





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] passthru environment variables

2001-02-13 Thread Rich Puchalsky

OK, I finally found it.  Someone else here recommended setenv -- it's
actually putenv.  putenv was *not* found through any search I could make on
the PHP Web site involving the word environment and so on, I found it
through Google.  And it's apparently documented under "PHP Options and
Information" where I wouldn't have thought to look for it for a thousand
years.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] passthru environment variables

2001-02-12 Thread Tim Ward

fpassthru doesn't include the code in your php code. In just dumps the file
to output as it runs. Anything defined in PHP (inluding variables and
functions) in the file passed through will not be available to the calling
program. You need include();

Tim Ward
Senior Systems Engineer

Please refer to the following disclaimer in respect of this message:
http://www.stivesdirect.com/e-mail-disclaimer.html


 -Original Message-
 From: Rich Puchalsky [mailto:[EMAIL PROTECTED]]
 Sent: 11 February 2001 05:52
 To: [EMAIL PROTECTED]
 Subject: [PHP] passthru environment variables
 
 
 I'm trying to use passthru in a PHP program to have an 
 external program
 display some data.  The problem is that I was trying to have 
 the external
 program's environment pick up the form field variables 
 automatically passed
 into the PHP program as shell environment variables.
 
 In other words, if a user typed "Smith" into the last_name 
 field in a form,
 the PHP program called by that form starts out with 
 $last_name = "Smith",
 and I would like the external program called by passthru 
 within the PHP
 program to have a shell environment variable last_name = "Smith".
 
 Does anyone know an easy way to do this?
 
 
 
 
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] passthru environment variables

2001-02-11 Thread Richard Lynch

 I'm trying to use passthru in a PHP program to have an external program
 display some data.  The problem is that I was trying to have the external
 program's environment pick up the form field variables automatically
passed
 into the PHP program as shell environment variables.

 In other words, if a user typed "Smith" into the last_name field in a
form,
 the PHP program called by that form starts out with $last_name = "Smith",
 and I would like the external program called by passthru within the PHP
 program to have a shell environment variable last_name = "Smith".

 Does anyone know an easy way to do this?

http://php.net/setenv

?php
SetEnv("last_name='$last_name'");
?

Since you probably want to do this for all your POST vars, check out
http://php.net/FAQ.php#7.1
?php
reset($HTTP_POST_VARS);
while (list($var, $val) = each($HTTP_POST_VARS)){
SetEnv("$var='$val'");
}
?

--
Visit the Zend Store at http://www.zend.com/store/
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] passthru environment variables

2001-02-11 Thread Rich Puchalsky

"Richard Lynch" [EMAIL PROTECTED] wrote:
 http://php.net/setenv

Thanks!  But when I try this link, or the "Quick Ref" button on the PHP home
page, I can't find anything about setenv.  And the manual doesn't have
anything about it under Program Execution Functions.  Is it undocumented?




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] passthru environment variables

2001-02-11 Thread Rich Puchalsky


"Rich Puchalsky" [EMAIL PROTECTED] wrote in message
966dad$pkm$[EMAIL PROTECTED]">news:966dad$pkm$[EMAIL PROTECTED]...
 "Richard Lynch" [EMAIL PROTECTED] wrote:
  http://php.net/setenv

 Thanks!  But when I try this link, or the "Quick Ref" button on the PHP
home
 page, I can't find anything about setenv.  And the manual doesn't have
 anything about it under Program Execution Functions.  Is it undocumented?

And once I actaully tried it, I got an undefined function message.




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] passthru environment variables

2001-02-10 Thread Rich Puchalsky

I'm trying to use passthru in a PHP program to have an external program
display some data.  The problem is that I was trying to have the external
program's environment pick up the form field variables automatically passed
into the PHP program as shell environment variables.

In other words, if a user typed "Smith" into the last_name field in a form,
the PHP program called by that form starts out with $last_name = "Smith",
and I would like the external program called by passthru within the PHP
program to have a shell environment variable last_name = "Smith".

Does anyone know an easy way to do this?





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]