I would like to use open pipe with a program sending it's output to sterr rather to stdout.
Is it some way to do that? (Open pipe seems not to be able to access stderr.)
Regards
Stderror
-
- Posts: 5494
- Joined: Sep 12, 2005 20:06
- Location: California
There's Open Error, which makes me unsure as to whether stderr can be accessed as a pipe. Looks like stdout might handle that.
@Bunuel
Windows or *nix?
If Windows, I find that STDOUT and STDERR both appear as STDIN to open pipe with fb v.20. Using this test of STDERR:
[You can test this to verify that it is printing only to STDERR]
And then this as test of open:
I get "Now is the time".
'
I expected to have to redirect STDERR in the pipe:
open pipe "stderr-1.exe 2>&1" for input as #1
but that isn't necessary for me on XP.
'
So my experience with Windows XP is that "open pipe" is capturing STDIN and STDERR as one (folding both into STDIN).
'
You are using what version of fb on what OS?
Windows or *nix?
If Windows, I find that STDOUT and STDERR both appear as STDIN to open pipe with fb v.20. Using this test of STDERR:
Code: Select all
'compile as stderr-1.exe
#include once "crt.bi"
'
dim as integer res
res=fprintf(STDERR,!"Now is the time\n")
'
end
And then this as test of open:
Code: Select all
dim as string s
open pipe "stderr-1.exe" for input as #1
while not eof(1)
line input #1,s
print s
wend
'
end
'
I expected to have to redirect STDERR in the pipe:
open pipe "stderr-1.exe 2>&1" for input as #1
but that isn't necessary for me on XP.
'
So my experience with Windows XP is that "open pipe" is capturing STDIN and STDERR as one (folding both into STDIN).
'
You are using what version of fb on what OS?
-
- Posts: 5494
- Joined: Sep 12, 2005 20:06
- Location: California
I made a test as well.
StdErrTest: Opens up testprog, passes the name of stderrtest to the testprog, and then passes a second argument which will be printed through stderr by testprog.
Testprog: Gets the name of the exe that called it, opens up its output stream and prints data back to it as well as the stderr stream.
stderrtest.bas
testProg.bas
StdErrTest: Opens up testprog, passes the name of stderrtest to the testprog, and then passes a second argument which will be printed through stderr by testprog.
Testprog: Gets the name of the exe that called it, opens up its output stream and prints data back to it as well as the stderr stream.
stderrtest.bas
Code: Select all
dim as integer ff = freefile()
dim as string tempStr
open pipe "testProg.exe stderrtest.exe foo" for input as #ff
while not EOF(ff)
line input #ff, tempStr
print tempStr
wend
close #ff
sleep
Code: Select all
dim as integer fferr = freefile()
dim as integer ffout = freefile()
dim as string cmnd = command(1)
open err for output as #fferr
open pipe cmnd for output as #ffout
print #ffout, "Hello, " & cmnd
print #fferr, "RANDOM ERROR BECAUSE OF: " & command(2)
close #ffout
close #fferr
After some thought.. STDERR is not wrapped in with STDIN in "open pipe", Bunuel66 is correct that "open pipe" doesn't capture STDERR. So it is necessary to redirect STDERR.
This is a better test, and reflects redirecting STDERR:
This is a better test, and reflects redirecting STDERR:
Code: Select all
dim as string s
open pipe "stderr-1.exe 2>&1" for input as #1
while not eof(1)
line input #1,s
if not eof(1) then
color 12,0 'if isn't red STDERR wasn't redirected
print "s= ";s 'if no "s= "..
end if
wend
'
sleep
end
Still in trouble....
Thanks guys for the suggestions. As said by zippy stderr is not handled by the pipe.
I have tried a lot of combinations without success.
To be more detailed, I I'm trying to catch the output of the java compiler "javac" for displaying it in an IUP window.
I'm running FBC under Ubuntu 8.04.1
I have found a work around using javac -XStdout for forcing the output to an intermediate file.
But no way to do it directly......If somebody has an idea....
Regards
Luis
I have tried a lot of combinations without success.
To be more detailed, I I'm trying to catch the output of the java compiler "javac" for displaying it in an IUP window.
I'm running FBC under Ubuntu 8.04.1
I have found a work around using javac -XStdout for forcing the output to an intermediate file.
But no way to do it directly......If somebody has an idea....
Regards
Luis
-
- Posts: 1706
- Joined: May 27, 2005 6:34
- Location: Cambodia, Thailand, Lao, Ireland etc.
- Contact: