Re: Saving all xterm output to a file

2009-02-08 Thread Thomas Dickey

On Sat, 7 Feb 2009, Gary Johnson wrote:


../run 1 Joiner default 21  results.dat


I think that has to be written this way:

   ../run 1 Joiner default  results.dat 21

But if you (the OP) wants to see what's going into that file, you
should tee, like this:

   ../run 1 Joiner default 21 | tee results.dat


hmm - yes (I had at hand a script which does the latter, and couldn't
recall the detail needed for the former, which seemed to be what OP 
requested).


--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/



Re: Saving all xterm output to a file

2009-02-08 Thread Mark J. Reed
On Sun, Feb 8, 2009 at 6:35 AM, Thomas Dickey  wrote:
 hmm - yes (I had at hand a script which does the latter, and couldn't
 recall the detail needed for the former, which seemed to be what OP
 requested).

Redirects are processed left-to-right.  So this:

command foo 21

says send stdout into file foo and then send stderr (file descriptor
2) wherever stdout (file descriptor 1) is going.  So they both go
into the file.  If you swap them, like this:

command 21 foo

that says send stderr wherever stdout is going, and then send stdout
into file foo.  Which means stderr goes to the screen like usual and
the 21 doesn't do much in this case.  But since pipes are set up
before any of the redirects, this command:

command 21 foo | othercommand

will send stdout into a file while piping stderr into the other
command, and this one:

command 21 | othercommand

will pipe them both together.

-- 
Mark J. Reed markjr...@gmail.com

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/



Re: Saving all xterm output to a file

2009-02-08 Thread teddybouch

Sorry, I'm not entirely sure I understood all that, but I wanted to give an
update. I wrote a script and ran over 250 tests over last night using this
syntax:

./run 1 Joiner default 21 | tee 2_7_09_results.dat

Only one of these tests gave output. Mark, if I understand you correctly,
the | tee should be at the end? I will try that today. 

A few more details about the system, in case any of them matter. All of this
is running on a MacBook Pro that is running Windows XP in Bootcamp. What the
run program does is actually start up a few different processes, one of
which I wrote, to control a robot in a simulation package. The program that
I wrote has  bunch of printout statements that I need to see to debug why it
isn't working and to take data once it is. I should mention that what I have
been doing is completely closing out XWin after every run and re-opening it.
I'm not sure if this will cause problems, and since it was test #67 that
gave results last night, I don't think that would be the problem, but I'm
going to try just closing bash and xterm between runs today.
-- 
View this message in context: 
http://www.nabble.com/Saving-all-xterm-output-to-a-file-tp21894608p21898633.html
Sent from the cygwin-xfree mailing list archive at Nabble.com.


--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/



Re: Saving all xterm output to a file

2009-02-08 Thread Jon TURNEY

teddybouch wrote:

Sorry, I'm not entirely sure I understood all that, but I wanted to give an
update. I wrote a script and ran over 250 tests over last night using this
syntax:

./run 1 Joiner default 21 | tee 2_7_09_results.dat

Only one of these tests gave output. Mark, if I understand you correctly,
the | tee should be at the end? I will try that today. 


A few more details about the system, in case any of them matter. All of this
is running on a MacBook Pro that is running Windows XP in Bootcamp. What the
run program does is actually start up a few different processes, one of
which I wrote, to control a robot in a simulation package. The program that
I wrote has  bunch of printout statements that I need to see to debug why it
isn't working and to take data once it is. I should mention that what I have
been doing is completely closing out XWin after every run and re-opening it.
I'm not sure if this will cause problems, and since it was test #67 that
gave results last night, I don't think that would be the problem, but I'm
going to try just closing bash and xterm between runs today.


If you really want to prove this is an xterm issue (which seems unlikely to me 
as this really revolves about what bash is doing), you should compare the 
behaviour between running the command under an xterm and running it under some 
other terminal emulator (e.g. the 'cygwin bash shell' menu shortcut which 
starts bash inside the native 'DOS window')



It was working alright, but
then I realized that it wasn't getting all the output that ought to be
there. Now, it has progressed to the point that I'm not getting any of the
printout statements at all - they don't appear in the xterm window or in the
file.


It sounds like your output is gradually getting less and less.  But you don't 
really say what's changing here: the scripts you are running, the environment 
you are running them in, or just the output?



--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/



Re: Saving all xterm output to a file

2009-02-08 Thread teddybouch

Okay, I'm digging a little deeper, and I think that I have noticed some
things that might be helpful and I've created some files that might shed
some light.

The files below are output from what I'm running through xterm. Auto
indicates simulations in which the output was automatically teed to a file
as well as the file, while manual indicates that I ran the simulation
without having it output to a file and cut-and-paste the output to the text
file. Good indicates that the simulation ran the way that I wanted it to,
and bad indicates that there was an unrelated error that caused the
simulation to fail. The file labeled with BadOut ran the way that I wanted,
but this problem that I'm trying to fix came up where the output didn't go
to the file.

http://www.quickfilepost.com/download.do?get=2aeda11324087e4b50df06b338aa32fa
Output_Auto_Bad.txt 
http://www.quickfilepost.com/download.do?get=51d9196b285962f05ab40ce620d1a75c
Output_Auto_Good.txt 
http://www.quickfilepost.com/download.do?get=6922453eb0a8cbf34d0188ebd8d9c3bc
Output_Auto_Good_BadOut.txt 
http://www.quickfilepost.com/download.do?get=cf14ab8cd7f2767f2ea4cfbb49c8544b
Output_Manual_Bad.txt 
http://www.quickfilepost.com/download.do?get=dae384fed148e62ada7d5c02661b68b1
Output_Manual_Good.txt 

The most useful thing is to look at the first lines of each down to where it
says Adm. I noticed that the output from this first part is consistent no
matter if the output I need shows up or not - the same initialization stuff
shows up. The funny thing is that that initialization stuff is unique to the
different processes that are starting. Now, the program that outputs Adm
is the same program that should be creating all the output that I want to
save, so I'm not sure that this theory holds water, but I wanted to throw it
out there.
-- 
View this message in context: 
http://www.nabble.com/Saving-all-xterm-output-to-a-file-tp21894608p21903611.html
Sent from the cygwin-xfree mailing list archive at Nabble.com.


--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/



Re: Saving all xterm output to a file

2009-02-08 Thread Larry Hall (Cygwin X)

teddybouch wrote:



Jon TURNEY wrote:


If you really want to prove this is an xterm issue (which seems unlikely
to me 
as this really revolves about what bash is doing), you should compare the 
behaviour between running the command under an xterm and running it under
some 
other terminal emulator (e.g. the 'cygwin bash shell' menu shortcut which 
starts bash inside the native 'DOS window')





I'm not really partial to proving that this is an xterm issue - I just want
to get it working the way I need it to. Right after I write this email I'm
going to make another version of my control program that writes directly to
a file and see if that will give me everything that I need. I took your
advice and tried it under the cygwin bash shell and got the same problem, so
I assume that it's not an xterm issue, but as you suggest, a bash issue. If
this isn't the place to find help for that, could someone direct me to the
correct venue, please?


For non-X issues, you want the main Cygwin list.  But before jotting off a
note there, see below.


As to the issue of changing output, I'm sorry that the parameters for the
different results were ambiguous. The input was the same for all of them.
The change in output is not a progressive thing - it's just that sometimes
the printf statements in my code get written to the specified file and other
times they do not. Interestingly enough, the printf statements in the
portion of the code that I didn't write do get output consistently. They are
each followed by called to fflush(stdout) - might this have something to do
with it?


This has _everything_ to do with it.  You're obviously suffering from
buffered I/O.  Employ the same technique as you've found in other areas
and I expect your program will output everything like you expect when you
expect it.

--
Larry Hall  http://www.rfk.com
RFK Partners, Inc.  (508) 893-9779 - RFK Office
216 Dalton Rd.  (508) 429-6305 - FAX
Holliston, MA 01746

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/



Re: Saving all xterm output to a file

2009-02-08 Thread teddybouch

That's it! If I just throw some of the fflush commands in here and there in
strategic places, I get all the output I am looking for up to those
statements. Why would this be needed sometimes and not others?
-- 
View this message in context: 
http://www.nabble.com/Saving-all-xterm-output-to-a-file-tp21894608p21906401.html
Sent from the cygwin-xfree mailing list archive at Nabble.com.


--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/



Re: Saving all xterm output to a file

2009-02-08 Thread Larry Hall (Cygwin X)

teddybouch wrote:

That's it! If I just throw some of the fflush commands in here and there in
strategic places, I get all the output I am looking for up to those
statements. Why would this be needed sometimes and not others?


It's always needed if you must have output at a particular point in the
execution.  If that's not a requirement, then it shouldn't be necessary
since the buffer should be flushed at normal program end.  If that's not
happening, that suggests something in your program is holding the stdout
handle open, it has set the buffer size to something extraordinarily large,
or you've triggered a bug.  If you believe it's a bug, please create
a simple test case in C that demonstrates the problem.  Send it to the
Cygwin list with an explanation of the problem.

--
Larry Hall  http://www.rfk.com
RFK Partners, Inc.  (508) 893-9779 - RFK Office
216 Dalton Rd.  (508) 429-6305 - FAX
Holliston, MA 01746

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/



Saving all xterm output to a file

2009-02-07 Thread teddybouch

I am trying to automate a simulation process, and part of this involves
capturing the output that is written to an xterm window when a particular
process is run. I thought that I had this figured out using the following
command:

./run 1 Joiner default  results.dat

run is the program that I am running and want to catch the output of. 1,
Joiner, and default are parameters needed by that program. results.dat
is the file that I want the output written to. It was working alright, but
then I realized that it wasn't getting all the output that ought to be
there. Now, it has progressed to the point that I'm not getting any of the
printout statements at all - they don't appear in the xterm window or in the
file.

What do I need to do to get this to work? Thanks very much for your help.

Andrew Bouchard
-- 
View this message in context: 
http://www.nabble.com/Saving-all-xterm-output-to-a-file-tp21894608p21894608.html
Sent from the cygwin-xfree mailing list archive at Nabble.com.


--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/



Re: Saving all xterm output to a file

2009-02-07 Thread Thomas Dickey

On Sat, 7 Feb 2009, teddybouch wrote:


I am trying to automate a simulation process, and part of this involves
capturing the output that is written to an xterm window when a particular
process is run. I thought that I had this figured out using the following
command:

../run 1 Joiner default  results.dat


fwiw, this isn't specific to X...


run is the program that I am running and want to catch the output of. 1,
Joiner, and default are parameters needed by that program. results.dat
is the file that I want the output written to. It was working alright, but
then I realized that it wasn't getting all the output that ought to be
there. Now, it has progressed to the point that I'm not getting any of the
printout statements at all - they don't appear in the xterm window or in the
file.


Perhaps you're looking for the messages written to stderr.
For that you need to redirect stderr as well, e.g.,

../run 1 Joiner default 21  results.dat

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/



Re: Saving all xterm output to a file

2009-02-07 Thread Gary Johnson
On 2009-02-07, Thomas Dickey wrote:
 On Sat, 7 Feb 2009, teddybouch wrote:
 
 I am trying to automate a simulation process, and part of this involves
 capturing the output that is written to an xterm window when a particular
 process is run. I thought that I had this figured out using the following
 command:
 
 ../run 1 Joiner default  results.dat
 
 fwiw, this isn't specific to X...
 
 run is the program that I am running and want to catch the output of. 1,
 Joiner, and default are parameters needed by that program. 
 results.dat
 is the file that I want the output written to. It was working alright, but
 then I realized that it wasn't getting all the output that ought to be
 there. Now, it has progressed to the point that I'm not getting any of the
 printout statements at all - they don't appear in the xterm window or in 
 the
 file.
 
 Perhaps you're looking for the messages written to stderr.
 For that you need to redirect stderr as well, e.g.,
 
 ../run 1 Joiner default 21  results.dat

I think that has to be written this way:

../run 1 Joiner default  results.dat 21

But if you (the OP) wants to see what's going into that file, you
should tee, like this:

../run 1 Joiner default 21 | tee results.dat

HTH,
Gary



--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/



Re: Saving all xterm output to a file

2009-02-07 Thread teddybouch

Thanks very much. The tee works well, and is particularly helpful for
debugging. Unfortunately, it seems that sometimes the program will run and
display output as it ought to, and other times it will run and no output is
visible. I've never had this problem when not trying to output to a file, so
I am assuming that it has to do with that. Any ideas?
-- 
View this message in context: 
http://www.nabble.com/Saving-all-xterm-output-to-a-file-tp21894608p21896001.html
Sent from the cygwin-xfree mailing list archive at Nabble.com.


--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://x.cygwin.com/docs/
FAQ:   http://x.cygwin.com/docs/faq/