I want to get the output of tail -f /var/log/apache2/error.log | grep “trace1” into a file. But tail -f /var/log/apache2/error.log | grep “trace1” > output.txt does not work, while the first command gives an output in my terminal window as expected. I guess it has to do with the fol…
Tag: stdout
Why does read block on a pipe until the write end is closed?
I’m trying to bolster my understanding of things related to fork, exec, dup, and redirecting stdin/stdout/stderr by writing the following popen-type function: Compilation and execution: My question is about the read() – I don’t quite grok why does the read() is seemingly block until the chil…
Write background command output (stdout) to file during execution
I have a command that takes a long time that I like to run in the background like this: This works perfectly in the sense that the command is indeed in the background and I can check the output and potential errors later. The main problem is the output is only appended after the command is completely finished…
How to view stdout in AWS environment?
Below is the lambda function: executed with NodeJS runtime ( as serverless app) that writes the incoming event record to stdout By definition, console.log prints to stdout, as mentioned here, but I need to go through cloud watch logs, as this is AWS serverless app: What is the correct way to view stdout in AW…
Shell script: Redirect output of program to changing files
My goal: I would like to redirect the stdout output of my program foo to a changing output file depending on the running time of the program. The program foo itself is listening on a bsd socket for arriving packets and displays information contained in them. So essentially, after running the program foo for 1…
Using unbuffered pipe as “dummy” file output
I’ve been dealing with a weird issue that I can’t find a way to solve. My situation is as follows. I have an application in python called “app1”, that requires a file for outputting the results of it’s execution. I have a secondary application, called “app2”; a binary…
How to get logs of individual argument passed to shell script from a file
I have a shell script. In this script I am reading table names for a file and executing a command. The script is working fine. I am able execute the command for all the tables in the file. shell script In this script I want to collect status logs and stdout logs. I want to collect the logs for each
how to output only when command finish
I’m running multiple commands using &: This doesn’t work well because the output lines are interleaved. I want each curl to hold its output, until it’s done. How to do that? I understand I can use temp files, concat together and delete afterwards. Are there better ways? Answer You could …
Why cat 0>file doesn’t work
In Unix, I know that 0 1 and 2 represent stdin stdout and stderr. As my understanding, the command cat meaning “concatenate” can concatenate different files. For example, cat file>&1 can concatenate the file and the stdout and the arrow means the redirection from the fileto the stdout, so w…
Redirecting stdout and stderr to a file in c++
I am trying to redirect stdout and stderr to a log file. This is what i am doing. But still i am missing out some of the logs. I came to know that when i executed my application commenting out these lines of code. I am dubious about this code snippet. Please provide your feedback on this. Answer first close