4,822 questions
Advice
0
votes
6
replies
127
views
Capture stderr while passing stdout to a pipe
My question is similar to How can I pipe stderr, and not stdout?
The following captures ALL the output from the cat command in a variable
_output="$(cat "$_filename" 2>&1)"
...
3
votes
1
answer
136
views
Issues with redirecting output text to a separate window in Python
I am very, very new to programming having just finished a semester-long course on Python. I wanted to take an existing program I had written for my class and redirect all the output text to a separate ...
2
votes
3
answers
185
views
How to get 'stdout' output from 'git gc 2>&1' on Windows PowerShell?
In PowerShell git gc normally produces some info output such as:
PS C:\myrepo> git gc
Enumerating objects: 12172, done.
Counting objects: 100% (12172/12172), done.
Delta compression using up to 12 ...
0
votes
1
answer
97
views
PyQt: how to view stdout and stderr in real time without the possibility of accidentally closing the terminal
I have a fairly complex PyQt application running on Windows that runs with a terminal (python.exe instead of pythonw.exe).
It's always been quite handy to be able to see stdout and stderr in real time ...
4
votes
1
answer
158
views
Unable to flush stdout: Bad file descriptor
foobar is a Perl script that prints to both standard output and standard error. In a separate Perl script echo-stderr, I run foobar and capture its standard error using IPC::Open3's open3 function, ...
Advice
0
votes
3
replies
92
views
SLURM: Write output file on the fly
I have a program that writes info in the screen, does some stuff, prints again, and so on. For example, the program is julia MWE.jl, where MWE.jl is the file
for ii=1:50
println("ii=",ii)...
0
votes
0
answers
34
views
Is it possible to configure expect to not close stdout when stdin is closed?
Consider the following expect script:
#!/usr/bin/env expect -f
send "Hello world"
expect eof
send "Goodbye world"
I would like the output to be Hello world followed by Goodbye ...
0
votes
0
answers
138
views
Spawning a python subprocess and suppress output of it and its children
I'm running an utility for using kubernetes via the model context protocol. I can call it from the shell like this (using the uv tool utilities): uvx kubernetes-mcp-server --port 8080. I am spawning ...
1
vote
2
answers
170
views
How to make a copy of stdout that does not close?
I would want to copy sys.stdout such that it will not be closed.
There is some generic code that does:
def dosomething(fd: IO[bytes], input):
with fd as f:
for buf in input:
f.write(...
1
vote
1
answer
91
views
Mock patch sys.stdout to StringIO as a decorator
I am trying to mock.patch sys.stdout to StringIO as a decorator to record the output for testing.
As a 'with' statement it works this way:
with mock.patch('sys.stdout', new_callable = StringIO) as ...
0
votes
0
answers
109
views
How to stop last prompt line from flickering while printing lines above it in a loop?
I'm working with Node.js (ESM .mjs file) on macOS terminal.
My printing logic is:
Start printing from the current top line in the terminal downward.
Continuously add new lines (Hello, world! ) in ...
1
vote
1
answer
151
views
printf (inside C code) called from python in google colab. (no output)
printf doesn't output anything
google colab cell:
%%writefile my_functions.c
#include <stdio.h>
#include <stdlib.h>
void my_void_func() {
printf("my_void_func called from C!\n");
...
5
votes
3
answers
272
views
Redirect stdout at a file-descriptor level to silence noisy module import
I have a module that I need to use. However, when it is imported, it helpfully prints out some status information.
> import problematic_module
Connected to local cache!
Detected version 1.0.0!
<...
3
votes
3
answers
932
views
How can I execute a Python script in the REPL interpreter mode and get the exactly same output as if it was manually typed in? (Ubuntu, Python 3.12)
The Python interpreter can be run either in script or interactive/REPL mode.
I do have a Python script as text file but want to run it as if it was manually typed in in the interactive/REPL mode.
I ...
4
votes
4
answers
171
views
make bash subshells log to separate lines in stdout
I want to write a bash script that establishes an ssh connection to multiple hosts to execute a command. Because this can be very slow I want to do it in parallel using subshells and log the outputs ...