473,326 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Setting STDOUT in program

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
Dec 11 '07 #1
7 2095
cipher wrote:
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.
js*******@attglobal.net
==================

Dec 11 '07 #2
On Tue, 11 Dec 2007 10:41:50 +0100, cipher <ma****************@gmail.com>
wrote:
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
Dec 11 '07 #3
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:
cipher wrote:
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
==================
Dec 11 '07 #4
cipher wrote:
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/
Dec 11 '07 #5
On Tue, 11 Dec 2007 13:00:53 +0100, cipher <ma****************@gmail.com>
wrote:
On 11 Dez., 12:12, Jerry Stuckle <jstuck...@attglobal.netwrote:
>cipher wrote:
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.
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
Dec 11 '07 #6
cipher wrote:
On 11 Dez., 12:12, Jerry Stuckle <jstuck...@attglobal.netwrote:
>cipher wrote:
>>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.
js*******@attglobal.net
==================

Dec 11 '07 #7
cipher wrote:
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/
Dec 11 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Harayasu | last post by:
Hi, Using fgets() I can read from stdin and with fputs() I can write to stdout. Now I have two programs, one writing to stdin and the other one reading from stdin. And I would like the second...
4
by: Rouben Rostamian | last post by:
Consider the following demo program: #include <stdio.h> int main(void) { unsigned char c; for (c=0; c<15; c++) putchar(c);
8
by: John Forkosh | last post by:
I have a C program that writes binary output to stdout, which works fine in Unix/Linux. But when someone else compiled and ran it in Windows, every time the program emitted a 0x0A, Windows...
8
by: Paul Edwards | last post by:
Is it permissible in C89 to do an "fclose(stdout)" and then exit, or is the C runtime library allowed to assume that stdout remains open and thus unconditionally do an fclose itself? Thanks. ...
20
by: David Mathog | last post by:
A program of mine writes to a tape unit. Output can be either through stdout or through a file opened with fopen(). When all the data is transferred to tape the program needs to close the output...
1
by: Torsten Bronger | last post by:
Hallöchen! I start a python script with subprocess from another Python script with python = subprocess.Popen(, stdout=subprocess.PIPE, stderr=subprocess.PIPE) However, this child script...
1
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, I have a C# application in which I start another process which produces output to stdout and stderr. In fact, that process is the uSoft VS2005 C/C++ compiler itself! I would like to...
0
by: kreismaler | last post by:
I have some problems to understand the difference of using the STDOUT and using "anonymous pipes" as shown below: using System; using System.Diagnostics; using System.IO; namespace...
4
by: lovecreatesbea... | last post by:
For example, in Bourne Shell both stdout and stderr can be re-directed to /dev/null, $ ./a.out 2>&1 /dev/null then is there any difference still?
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.