473,789 Members | 2,122 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2121
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*******@attgl obal.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...@attg lobal.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...@attgl obal.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.htm l

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...@attg lobal.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...@attg lobal.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...@attg lobal.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*******@attgl obal.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
18376
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 program to read the characters the first program has written to stdin, but I don't get it how to do this. The program which writes to stdin:
4
25678
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
6087
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 interpreted it as an lf, and preceded it with a spurious 0x0D cr. Cute. Is there some way I can freopen() (so to speak) stdout in binary mode under Windows so that doesn't happen? Hopefully, the fix would be portable, so it could compile and...
8
5944
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. Paul.
20
7311
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 stream so that the tape driver will write a filemark on the tape. Otherwise multiple clumps of data saved to tape would all appear to be one big file on the tape. When the tape unit device was explicitly opened with fopen() that's possible:...
1
4210
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 has sys.stdout.encoding set to None, which means that Unicode strings cannot be printed without trouble.
1
3769
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 capture the results of the compile and display them in a RichTextBox. The problem I'm having is that when I intentionally introduce an error in the C code I'm compiling, I can't read the error output in my C# program. I've tried redirecting both...
0
2612
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 ProcessTest { class Program
4
2297
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
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9499
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10374
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10177
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10121
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8995
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2898
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.