tee

Bash: tree direction in sub-shell working incorrectly

孤人 提交于 2020-01-15 10:48:49
问题 I tested this on a CentOS machine a while back and it worked nicely. Now on another machine, I try this and it fails to work. What is incorrect? command 2> >(tee stderr.log >&2) && exit I get this message back. sh: syntax error near unexpected token `>' Any suggestions? 回答1: The answer is in the error message. The traditional Bourne shell ( sh ) doesn't support process substitution (e.g. >(command) ). You weren't using Bash. You can change your default shell using the chsh command. 来源: https:

In bash tee is making function variables local, how do I escape this?

╄→尐↘猪︶ㄣ 提交于 2020-01-15 08:17:30
问题 I have stucked with a bash scipt which should write both to stdout and into file. I'm using functions and some variables inside them. Whenever I try to redirect the function to a file and print on the screen with tee I can't use the variables that I used in function, so they become local somehow. Here is simple example: #!/bin/bash LOGV=/root/log function var() { echo -e "Please, insert VAR value:\n" read -re VAR } var 2>&1 | tee $LOGV echo "This is VAR:$VAR" Output: [root@testbox ~]# ./var

How to stream tmux pipe-pane via UDP

旧城冷巷雨未停 提交于 2020-01-13 06:33:58
问题 I'm trying to simultaneously save the output from a tmux pane to file and stream it using netcat. What works: tmux pipe-pane -o -t "server" "tee -a '/home/csgoserverp/test.txt'" echo -n "Hello World" | tee -a '/home/me/text.txt' | nc -4u -w1 0.0.0.0 9999 What does not work: tmux pipe-pane -o -t "server" "nc -4u -w1 0.0.0.0 9999" tmux pipe-pane -o -t "server" "tee -a '/home/me/test.txt' | nc -4u -w1 0.0.0.0 9999" Any help would be appreciated. 回答1: I read somewhere that ncat is better than

In bash how do I exit a script from a function that is piped by tee?

╄→гoц情女王★ 提交于 2020-01-03 15:33:07
问题 I'm trying to understand why whenever I'm using function 2>&1 | tee -a $LOG tee creates a subshell in function that can't be exited by simple exit 1 (and if I'm not using tee it works fine). Below the example: #!/bin/bash LOG=/root/log.log function first() { echo "Function 1 - I WANT to see this." exit 1 } function second() { echo "Function 2 - I DON'T WANT to see this." exit 1 } first 2>&1 | tee -a $LOG second 2>&1 | tee -a $LOG Output: [root@linuxbox ~]# ./1.sh Function 1 - I WANT to see

How does the POSIX 'tee' command work?

て烟熏妆下的殇ゞ 提交于 2020-01-02 06:26:13
问题 tee newOutputFile < existingInputFile > newOutputFile2 How exactly will tee take in the arguments? Would it be like this? Tee will first process newOutputFile < existingInputFile So the contents of existingInputFile will be written into newOutputFile newOutputFile > newOutputFile2 So the contents of newOutputFile will be written into newOutputFile 2 I am trying to write a shell that process this particular command. However, I am confused as to which order to pass in the arguments to tee . The

tee stdout and stderr to separate files while retaining them on their respective streams

十年热恋 提交于 2019-12-31 13:14:31
问题 I'm trying to write a script the essentially acts as a passthru log of all the output created by a (non-interactive) command, without affecting the output of the command to other processes. That is to say, stdout and stderr should appear the same as if they had not run through my command. To do this, I'm trying to redirect stdout and stderr separately to two different tees, each for a different file, and then recombine them so that they still appear on stdout and stderr, respectively. I have

tee stdout and stderr to separate files while retaining them on their respective streams

半世苍凉 提交于 2019-12-31 13:14:13
问题 I'm trying to write a script the essentially acts as a passthru log of all the output created by a (non-interactive) command, without affecting the output of the command to other processes. That is to say, stdout and stderr should appear the same as if they had not run through my command. To do this, I'm trying to redirect stdout and stderr separately to two different tees, each for a different file, and then recombine them so that they still appear on stdout and stderr, respectively. I have

How to read data from QNetworkReply being used by QWebPage?

随声附和 提交于 2019-12-28 13:56:09
问题 I use QWebPage to download a webpage as well as all its resources. At the same time I'd like to get hold on raw data being downloaded by Qt during this process. Doing this by reading data from QNetworkReply in void QNetworkAccessManager::finished(QNetworkReply * reply) signal is not a good solution as data could have been already read by QWebPage itself. This is because QNetworkReply is a sequential-access QIODevice, which means that once data is read from the object, it no longer kept by the

Use tee (or equivalent) but limit max file size or rotate to new file

情到浓时终转凉″ 提交于 2019-12-28 05:21:25
问题 I would like to capture output from a UNIX process but limit max file size and/or rotate to a new file. I have seen logrotate, but it does not work real-time. As I understand, it is a "clean-up" job that runs in parallel. What is the right solution? I guess I will write a tiny script to do it, but I was hoping there was a simple way with existing text tools. Imagine: my_program | tee --max-bytes 100000 log/my_program_log Would give... Always writing latest log file as: log/my_program_log Then

How to replicate tee behavior in Python when using subprocess?

喜欢而已 提交于 2019-12-28 01:51:51
问题 I'm looking for a Python solution that will allow me to save the output of a command in a file without hiding it from the console. FYI: I'm asking about tee (as the Unix command line utility) and not the function with the same name from Python intertools module. Details Python solution (not calling tee , it is not available under Windows) I do not need to provide any input to stdin for called process I have no control over the called program. All I know is that it will output something to