Connecting Tech Pros Worldwide Forums | Help | Site Map

Setting STDOUT in program

cipher
Guest
 
Posts: n/a
#1: Dec 11 '07
Hi!

Is there a way to set STDOUT in a PHP script dynamically (by command
line argument,...)? I have large blocks of non-PHP-code (outside <?
php... ?>) and I don't want to use "print" for all these lines.

Greetings,

Markus

Jerry Stuckle
Guest
 
Posts: n/a
#2: Dec 11 '07

re: Setting STDOUT in program


cipher wrote:
Quote:
Hi!
>
Is there a way to set STDOUT in a PHP script dynamically (by command
line argument,...)? I have large blocks of non-PHP-code (outside <?
php... ?>) and I don't want to use "print" for all these lines.
>
Greetings,
>
Markus
>
I don't understand. If it's outside the <?php ... ?>, they should just
be printed anyway.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Rik Wasmus
Guest
 
Posts: n/a
#3: Dec 11 '07

re: Setting STDOUT in program


On Tue, 11 Dec 2007 10:41:50 +0100, cipher <markus.doerschmidt@gmail.com>
wrote:
Quote:
Hi!
>
Is there a way to set STDOUT in a PHP script dynamically (by command
line argument,...)? I have large blocks of non-PHP-code (outside <?
php... ?>) and I don't want to use "print" for all these lines.
>
Anything outside <?php ?blocks will go to PHP's STDOUT (possible
captured in output buffers if you like). On the command line you can
simple direct the STDOUT (and/or STDERR) to whatever you like...
--
Rik Wasmus
cipher
Guest
 
Posts: n/a
#4: Dec 11 '07

re: Setting STDOUT in program


Yes, I know that. But how can I redirect the script's output to a
file, if I call the script from command line and if I don't want to
use pipes?

On 11 Dez., 12:12, Jerry Stuckle <jstuck...@attglobal.netwrote:
Quote:
cipher wrote:
Quote:
Hi!
>
Quote:
Is there a way to set STDOUT in a PHP script dynamically (by command
line argument,...)? I have large blocks of non-PHP-code (outside <?
php... ?>) and I don't want to use "print" for all these lines.
>
Quote:
Greetings,
>
Quote:
Markus
>
I don't understand. If it's outside the <?php ... ?>, they should just
be printed anyway.
>
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
Toby A Inkster
Guest
 
Posts: n/a
#5: Dec 11 '07

re: Setting STDOUT in program


cipher wrote:
Quote:
Is there a way to set STDOUT in a PHP script dynamically (by command
line argument,...)? I have large blocks of non-PHP-code (outside <?
php... ?>) and I don't want to use "print" for all these lines.
Not sure what you're asking. STDOUT can be redirected in most shells to a
file using a construction like this:

php myscript.php >somefile.html

Or piped into STDIN of some other program using:

php myscript.php | someprogram

This is supported in bash, csh, zsh -- any shell I can think of. Even
DOS's COMMAND.COM.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 3 days, 22:23.]

Sharing Music with Apple iTunes
http://tobyinkster.co.uk/blog/2007/1...tunes-sharing/
Rik Wasmus
Guest
 
Posts: n/a
#6: Dec 11 '07

re: Setting STDOUT in program


On Tue, 11 Dec 2007 13:00:53 +0100, cipher <markus.doerschmidt@gmail.com>
wrote:
Quote:
On 11 Dez., 12:12, Jerry Stuckle <jstuck...@attglobal.netwrote:
Quote:
>cipher wrote:
Quote:
Hi!
>>
Quote:
Is there a way to set STDOUT in a PHP script dynamically (by command
line argument,...)? I have large blocks of non-PHP-code (outside <?
php... ?>) and I don't want to use "print" for all these lines.
>>
Quote:
Greetings,
>>
Quote:
Markus
>>
>I don't understand. If it's outside the <?php ... ?>, they should just
>be printed anyway.
Quote:
Yes, I know that. But how can I redirect the script's output to a
file, if I call the script from command line and if I don't want to
use pipes?
Why do you not 'want' to use pipes? What is it you are actually trying to
do?
--
Rik Wasmus
Jerry Stuckle
Guest
 
Posts: n/a
#7: Dec 11 '07

re: Setting STDOUT in program


cipher wrote:
Quote:
On 11 Dez., 12:12, Jerry Stuckle <jstuck...@attglobal.netwrote:
Quote:
>cipher wrote:
Quote:
>>Hi!
>>Is there a way to set STDOUT in a PHP script dynamically (by command
>>line argument,...)? I have large blocks of non-PHP-code (outside <?
>>php... ?>) and I don't want to use "print" for all these lines.
>>Greetings,
>>Markus
>I don't understand. If it's outside the <?php ... ?>, they should just
>be printed anyway.
>>
>--
>==================
>Remove the "x" from my email address
>Jerry Stuckle
>JDS Computer Training Corp.
>jstuck...@attglobal.net
>==================
>
>
Yes, I know that. But how can I redirect the script's output to a
file, if I call the script from command line and if I don't want to
use pipes?
>
(Top posting fixed)

You can't. That's the purpose of pipes.

You can buffer the output and write that to a file, but that's about it.

And please don't top post. Thanks.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Toby A Inkster
Guest
 
Posts: n/a
#8: Dec 11 '07

re: Setting STDOUT in program


cipher wrote:
Quote:
Yes, I know that. But how can I redirect the script's output to a file,
if I call the script from command line and if I don't want to use pipes?
Firstly, please quote correctly. Quote only the part of the post to which
you reply, and then place your reply underneath it.

Secondly, what have you got against pipes?

Lastly, ob_start() is what you want.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 3 days, 23:06.]

Sharing Music with Apple iTunes
http://tobyinkster.co.uk/blog/2007/1...tunes-sharing/
Closed Thread