Re: [PHP] stdin, stdout, stderr, 3

2009-03-09 Thread Daniel Brown
On Sun, Mar 8, 2009 at 22:35, Richard Lynch c...@l-i-e.com wrote:
 I have a program sending/receiving data to/from my CLI script using:

 0 stdin
 1 stdout
 2 stderr
 3 ??

UNIX Channel 3 is a non-standard stream resource, though I don't
believe it's even yet been given a name, so we'll have to change that.
 Let's call it STDOPT, because it's pretty much a STandarD OPTion that
you have available to use for your own desires (depending on the
distro and some other variables, you may not have STDOPT by default,
so as someone used to always sign their signature here, YMMV.)

 0, 1, and 2 are trivial.

 How do I access 3?

The same as you would in accessing channels 0, 1, and 2.  The
simplest way is to redirect STDOPT to STDOUT to view it on the screen:

?php
exec('./someCommand argument1 argument2 etc 31',$ret,$err);
print_r($ret); // Now contains a combination of STDOUT  STDOPT
print_r($err); // Still just STDERR.
?

Or you redirect STDOPT output to a file:

?php
exec('./someCommand argument1 argument2 etc 3stdopt.txt',$ret,$err);
print_r($ret); // STDOUT (Channel 1)
print_r($err); // STDERR (Channel 2)
echo file_get_contents('stdopt.txt'); // STDOPT (Channel 3)
?

 I tried /dev/fd/3 and failed to open it...

 Got no error messages about why it failed to open, it just failed.

 Am I missing something?

Make sure you have 'udev' installed on there, and also be sure
that /dev/fd exists, and /dev/fd/3 exists.  Also make sure that, when
you're checking it, STDERR isn't already being redirected somewhere
else, and that you're not missing some bad file descriptor errors in
the mix.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

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



Re: [PHP] stdin, stdout, stderr, 3

2009-03-09 Thread Per Jessen
Daniel Brown wrote:

 On Sun, Mar 8, 2009 at 22:35, Richard Lynch c...@l-i-e.com wrote:
 I have a program sending/receiving data to/from my CLI script using:

 0 stdin
 1 stdout
 2 stderr
 3 ??
 
 UNIX Channel 3 is a non-standard stream resource, though I don't
 believe it's even yet been given a name, so we'll have to change that.

UNIX Channel 3 ?? 
It's just file descriptor 3, that's all. In the old days, it was
occasionally called stdaux, but AFAIK that's not used any more. 


/Per

-- 
Per Jessen, Zürich (4.9°C)


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



RE: Re: [PHP] stdin, stdout, stderr, 3

2009-03-09 Thread Bob McConnell
From: Per Jessen
 Daniel Brown wrote:
 
 On Sun, Mar 8, 2009 at 22:35, Richard Lynch c...@l-i-e.com wrote:
 I have a program sending/receiving data to/from my CLI script using:

 0 stdin
 1 stdout
 2 stderr
 3 ??
 
 UNIX Channel 3 is a non-standard stream resource, though I don't
 believe it's even yet been given a name, so we'll have to change
that.
 
 UNIX Channel 3 ?? 
 It's just file descriptor 3, that's all. In the old days, it was
 occasionally called stdaux, but AFAIK that's not used any more. 

AUX and PRN for 3 and 4 were standard for a serial port and printer
interface respectively on CP/M and then PC-DOS 1.0. Both were carried
through to later versions of MS-DOS, but not used nor referenced very
much. I don't recall seeing them in a Unix context at all.

Bob McConnell

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



Re: [PHP] stdin, stdout, stderr, 3

2009-03-09 Thread Daniel Brown
On Mon, Mar 9, 2009 at 11:14, Per Jessen p...@computer.org wrote:

 UNIX Channel 3 ??

Sorry, Per, I must've stuttered.  Yes, I said, UNIX Channel 3.
For lack of a better reference.  That not withstanding, the direct
response to Lynch's question still holds true.

 It's just file descriptor 3, that's all. In the old days, it was
 occasionally called stdaux, but AFAIK that's not used any more.

Now that you mention it, I do seem to recall the term STDAUX,
but I'm not sure if it's an actual memory or just one of those things
that looks familiar after reading it.  Either way, the streams are
also referred to as channels, and the virtual reference to that is
known as the file descriptor.

 Per Jessen, Zürich (4.9°C)

It's about 43F (~6C) here in Scranton today much more
acceptable than the 5F (-15C) we had just a short time ago.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

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



Re: [PHP] stdin, stdout, stderr, 3

2009-03-09 Thread Per Jessen
Daniel Brown wrote:

 It's just file descriptor 3, that's all. In the old days, it was
 occasionally called stdaux, but AFAIK that's not used any more.
 
 Now that you mention it, I do seem to recall the term STDAUX,
 but I'm not sure if it's an actual memory or just one of those things
 that looks familiar after reading it.  Either way, the streams are
 also referred to as channels, and the virtual reference to that is
 known as the file descriptor.

Hmm, I know I have never heard streams or file descriptors referred to
as channels.  Well, certainly not in UNIX.  

As for stdaux, I don't think it's being used any more at all.  Like Bob
suggested, I think it might very well be a DOS reference. 



-- 
Per Jessen, Zürich (1.8°C)


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