tee

Bash: how to duplicate input/output from interactive scripts only in complete lines?

坚强是说给别人听的谎言 提交于 2019-12-11 01:38:15
问题 How can I capture the input/ output from a script in realtime (such as with tee), but line-by-line instead of character-by-character? My goal is to capture the input typed into the interactive prompts of a script only after backspaces and auto-completion have finished processing (after the RETURN key is hit). Specifically, I am trying to create a wrapper script for ssh that creates a timestamped log of commands used on remote servers. The script, which uses tee to redirect the output for

Why does tee wait for all subshells to finish?

流过昼夜 提交于 2019-12-10 21:20:23
问题 I have a server script that runs mysqld and forks to continue running. As an example: ./mysqld <parameters> & echo "Parent runs next line in script." <do more stuff> Why does tee wait for the child process to end before it ends itself? EDIT: For example, the following always hangs: ./myscript | tee -a logfile.log 回答1: Because it can't be sure it has tee'd all the output if the child process is still running (and still has its standard output open). Since the parent and child use the same

Piping a file through tail and head via tee [closed]

倖福魔咒の 提交于 2019-12-10 20:12:50
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . Starting from here I tried to read a file and emit the head and the tail of the file (reading the file only once). I tried the following: tee >(head) >(tail) > /dev/null < text.txt This line works as expected, but I'd like to get rid of the /dev/null. So I tried: tee >(head) | tail < text.txt But this line does

How to handle mirrored(duplicated) iptables traffic after TEE?

我怕爱的太早我们不能终老 提交于 2019-12-10 18:34:36
问题 I have a question about mirrored with TEE option iptables traffic. The main goal is to copy all traffic for service on server A (port 1935) to same service running on server B on same port (port 1935). For example: If I start streaming video to 192.168.0.200:1935 - video should be be on both servers (on 192.168.0.201:1935 and on 192.168.0.200:1935). Google point me to iptables -TEE option. I try to use it on Ubuntu: SERV A -192.168.0.200 SERV B -192.168.0.201 On SERV A (192.168.0.200) I add

Bash: Trap ERR does not work when pipe operator is used

China☆狼群 提交于 2019-12-10 17:39:04
问题 I am trying to log everything that comes out of stdout and stderr into a log file and still preserve the console. For this, I just appended: |& tee -a log_file.log to every command. However, I also want to run a custom command if any error occurred during the script. For this, I added the following at the beginning of the script: trap "echo Non-zero exit code detected" ERR . The problem is by using the pipe operator, the echo in the trap does not execute anymore. Script 1, without pipe: $cat

Tee does not exit after pipeline it's on has finished [closed]

余生颓废 提交于 2019-12-10 12:39:17
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . So, I've got a rather long and involved script intended to be used by people who aren't going to want to dig into anything that goes wrong. Recently,

Writing to multiple file descriptors with a single function call

左心房为你撑大大i 提交于 2019-12-10 10:39:55
问题 I had a use case for a group chat server where the server had to write a common string to all clients' socket. I had then addressed this by looping through the list of file descriptors and writing the string to each of the file descriptors. Now I am thinking of finding a better solution to the problem. Is it possible to do this by a single function call from the server by using the tee system call in linux. I want the output of one tee to go to the next tee as well to a clients socket. I am

Screen big data without interrupting data conversion

不羁的心 提交于 2019-12-08 11:37:45
问题 This thread is an extension of this thread where the interruption (CTRL-c) stop the data transfer into less. I would like to create a similar system monitoring data conversion as is found in fdupes . I think this can be reached with GNU screen . The tools tee and buffers may not be needed for this so skip the two sections if you want. Hex conversion and tee [skip if you know] You can use whatever hex dumper you want for the task, for instance hexdump -v , od -v -t x1 and xxd -ps for the

Redirect powershell output and errors to console (in real-time) and to a variable

走远了吗. 提交于 2019-12-08 04:41:13
问题 I would like to redirect the output of a command in PowerShell, following these rules: The command is stored to a variable Output must be written to the console in real-time (i.e. "ping" results), including errors Output must be stored to a variable, including errors (real-time is not mandatory here) Here are my tests, assuming: $command = "echo:" to test errors redirection, and: $command = "ping 127.0.0.1" to test real-time output. Output is written in real-time, errors are not redirected at

How does/frequent unix tee command write stdout terminal output to file? if the output is too big

限于喜欢 提交于 2019-12-07 16:57:42
问题 I am redirecting some tool stdout to tee command so that current progress can be seen on terminal as well as in the log file Here is the code snippet where I am running tool and its stdout is fed to tee command and this code snippet is written from tcl script. $(EH_SUBMIT) $(ICC_EXEC) $(OPTIONS) -f ./scripts/$@.tcl | tee -i ./logs/$@.log I can see current real time progress on the terminal but the same observation is not seen in the log file! and it writes stdout to log file chunk by chunk