tee

printing on screen and a text file

I need to dump the certain things into a text file and same has needs to be displayed on screen. (I'm telling about a C program utiltiy) The menu option looks like following, 1. display AA parameters 2. display BB parameters 3. display CC parameters 4. dump all 5. Exit Select option > If they select 1/2/3, it just needs to displayed ...

Where is the code for "tee" in Mac OS?

Where is the code for the terminal command 'tee' located in Mac OS? [Added] Is it possible to read the exact code, that my mac is using (not the online codes)? ...

How can I gzip standard in to a file and also print standard in to standard out?

I want to execute a command, have the output of that command get gzip'd on the fly, and also echo/tee out the output of that command. i.e., something like: echo "hey hey, we're the monkees" | gzip --stdout > my_log.gz Except when the line executes, I want to see this on standard out: hey hey, we're the monkees ...

How can I print intermediate results from a pipeline to the screen?

Duplicate http://stackoverflow.com/questions/570984/how-can-i-gzip-standard-in-to-a-file-and-also-print-standard-in-to-standard-out I'm trying to count the lines from a command and I'd also like to see the lines as they go by. My initial thought was to use the tee command: complicated_command | tee - | wc -l But that simply doubles ...

How do I duplicate sys.stdout to a log file in python?

Edit: Since it appears that there's either no solution, or I'm doing something so non-standard that nobody knows - I'll revise my question to also ask: What is the best way to accomplish logging when a python app is making a lot of system calls? My app has two modes. In interactive mode, I want all output to go to the screen as well as...

Unix: confusing use of the Tee -command

Manual states that the tee is a "pipe fitting"-tool. The cases [1] confuse me: 1. case echo "foo bar" | sudo tee -a /path/to/some/file 2. case :w !sudo tee % It is hard to understand the logic of tee from the cases. How does the tee work? ...

Unable to use multiple outputs in Zsh without tee

I have the following in .zshrc setopt multios I am trying to do the following with the above option enabled in Zsh ls -1 | tee file.txt | less I run the following command unsuccessfully ls -1 | file.txt | less and the following too ls -1, file.txt, less How can you use multiple outputs in Zsh without the command tee? ...

How to redefine clog to tee to original clog and a log file?

Hello, I saw a useful start here: http://www.cs.technion.ac.il/~imaman/programs/teestream.html And it works great to make a new stream which goes to both clog and a log file. However, if I try to redefine clog to be the new stream it does not work because the new stream has the same rdbuf() as clog so the following has no effect: cl...

How to redefine clog's rdbuf() to be a tee to the original rdbuf() of clog and that of a log file?

Hello, Does anyone have an example of how to redefine the C++ built in clog to instead have a new associated rdbuf() which is processed to be a tee to the original clog.rdbuf() and the rdbuf() of a ofstream object to a log file on disk. The intention is to have the code use the std::clog throughout but to have it go to the both the def...

tee and exit status

Guys, is there an alternative to "tee" which captures STDOUT/STDERR of the command being executed and exits with the same exit status as the processed command. Something as following: eet -a some.log -- mycommand --foo --bar Where "eet" is an imaginary alternative to "tee" :) (-a means append, -- separates the captured command) It shou...

python stdout flush and tee

The following code ends with broken pipe when piped into tee, but behave correctly when not piped : #!/usr/bin/python import sys def testfun(): while 1: try : s = sys.stdin.readline() except(KeyboardInterrupt) : print('Ctrl-C pressed') sys.stdout.flush() return ...

bash: tee output AND capture exit status

I want to execute a long running command in bash shell, and both capture its exit status, and tee its output. So I do this command | tee out.txt ST=$? The problem is that the variable ST captures the exit status of tee and not of command. How can I solve this? Note that command is long running and redirecting the output to a file to...

Vim: sudo errors in writing a selection

How can I circumvent the errors, such as E212 and E13, in the commands? :'a,'bw set_question_tags.php :'a,'bw >> set_question_tags.php In some cases, even with Pavel's command: "create_a_file_and_save.php" E212: Can't open file for writing ...

Broken pipes and tee?

The output of this echo is not passed on to the next command using pipe. echo 'set foreign_key_checks = 0; truncate table saurabh.bus_services;' | mysqldump --compact --no-create-info -h192.168.950.180 -uroot -p live pnlbus | more I want the set and truncate commands followed by the dump output. ...

PowerShell 1 is not capturing batch file output with tee

PowerShell can call commandline batch files. PowerShell script output can be recorded with the "tee" command. But the tee command does not record the output of batch files inside a PowerShell script for me in PowerShell 1. Try this cut-down example: Make a batch file, called test.bat, with contents @echo hello from bat Run it from P...

Compose output streams

I'd like to compose two (or more) streams into one. My goal is that any output directed to cout, cerr, and clog also be outputted into a file, along with the original stream. (For when things are logged to the console, for example. After closing, I'd like to still be able to go back and view the output.) I was thinking of doing somethin...

How can I implement 'tee' programmatically in C?

I'm looking for a way in C to programmatically (ie, not using redirection from the command line) implement 'tee' functionality such that my stdout goes to both stdout and a log file. This needs to work for both my code and all linked libraries that output to stdout. Any way to do this? ...

Troubleshooting SIGTERMs with tee on a cluster within SGE jobs

I have some legacy scientific code running on a Rocks cluster, with SGE. I have an application-specific job submission script that generates qsub scripts (i.e. the script which Sun Grid Engine takes and runs). Within the qsub script, my legacy app is called. This app sends it's output to STDOUT. SGE intercepts STDOUT and spools it into ...

Why tee’d variables aren’t visible in later scripblocks?

Someone knows for which strange reason Powershell doesn't show de 'tee'd' variable in the following snippet? # a.txt contains any text cat a.txt | tee -variable foovar | % { 'value of foovar: ' + $foovar } In practice, I'd like to do, in only one line, a search for some text and then, based on the results, process the text, for ...

bash: redirect (and append) stdout and stderr to file and terminal

To redirect (and append) stdout and stderr to a file, while also displaying it on the terminal I do this: command 2>&1 | tee -a file.txt However, is there another way to do this such that I get an accurate value for the exit status? That is if I test $?, I want to see the exit status of 'command' and not the exit status of tee. I kn...