How to store the output of a command in a variable at the same time as printing the output?
Use tee to direct it straight to screen instead of stdout $ var=$(echo hi | tee /dev/tty) hi $ echo $var hi
Use tee to direct it straight to screen instead of stdout $ var=$(echo hi | tee /dev/tty) hi $ echo $var hi
You can use the backtics to execute your external program and capture its stdout and stderr. By default the backticks discard the stderr and return only the stdout of the external program.So $output = `cmd`; Will capture the stdout of the program cmd and discard stderr. To capture only stderr you can use the shell’s … Read more
You might be able to do what you want with VT100 control codes. Something like this maybe: CURSOR_UP_ONE = ‘\x1b[1A’ ERASE_LINE = ‘\x1b[2K’ print(CURSOR_UP_ONE + ERASE_LINE)
Use the disp argument to fit. It controls the verbosity of the optimizers in scipy. mod.fit(disp=0) See the documentation for fit.
The original stdout can be accessed as sys.__stdout__. This is documented.
update-client 2>&1 | tee my.log 2>&1 redirects standard error to standard output, and tee sends its standard input to standard output and the file.
Firstly, +1 for realising how thread-unsafe many of the examples on stack overflow are! The solution is to use a thread-safe object (like a Python Queue.Queue) to mediate the transfer of information. I’ve attached some sample code below which redirects stdout to a Python Queue. This Queue is read by a QThread, which emits the … Read more
The ipython notebook has it’s own support for running shell commands. If you don’t need to capture with subprocess stuff you can just do cmd = ‘ls -l’ !{cmd} Output from commands executed with ! is automatically piped through the notebook.
Finally found that “demo”: https://github.com/asyncly/cdir/blob/223fe0039fade4fad2bb08c2f7affac3bdcf2f89/cdir.js#L24 http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x361.html http://ascii-table.com/ansi-escape-sequences-vt-100.php Position the Cursor: \u001b[<L>;<C>H or \u001b[<L>;<C>f (puts the cursor at line L and column C) Move the cursor up N lines: \u001b[<N>A Move the cursor down N lines: \u001b[<N>B Move the cursor forward N columns: \u001b[<N>C Move the cursor backward N columns: \u001b[<N>D Clear the screen, move to … Read more