3,926
questions
-2
votes
1
answer
55
views
Sphere Online Judge (SPOJ) Python input handling broken?
I'm fairly familiar with input handling in Competitive Programming settings, but I can't make it work in Python for this problem (https://www.spoj.com/problems/MINDIST/) (my solution works in C++ so ...
0
votes
1
answer
43
views
TCL: get 1 or 2 characters from user, discard other input
I'm trying to write a TCL script that reads from stdin channel 1 or 2 characters from user, discarding anything other from user input without reading it.
Malicious user can create a very long string ...
0
votes
4
answers
93
views
Asking for user input in a while loop in a bash script
I am running on Ubuntu 24.04.
I created a bash script that reads a file line by line in a loop and asks in this loop for a user input. (In fact it calls a function where this happens and something ...
0
votes
3
answers
56
views
Command `wc` with argument files and standard input redirection
I have come across the command line wc < f1 f2 and it's not clear for me what is happening under the hood:
$ echo -n 'a' > f1
$ wc f1
0 1 1 f1
$ echo -n 'bb' > f2
$ wc f2
0 1 2 f2
$ wc < ...
1
vote
1
answer
56
views
How to handle BufReader<File> and BufReader<Stdin> without dynamic dispatch?
I'm trying to create an object that can contain BufReader<File> and BufReader<Stdin> simultaneously. I'd like to avoid the more commonly used "trait object" (i.e. Box<dyn ...
0
votes
0
answers
46
views
Reading from stdout blocks using subprocess
new.py
print("Gib number")
x = input()
print('numba is ', x)
launcher.py
import subprocess as sp
p = sp.Popen(['python', 'new.py'], stdout=sp.PIPE, stderr=sp.STDOUT, stdin=sp.PIPE, text=...
0
votes
1
answer
45
views
Streaming large dataset to child process (as JSON)
I'm trying to send a large amount of data that is stored in memory to a child process. Specifically I have a large dataset represented as JSON in Node.js which I want to send to a child process I am ...
3
votes
1
answer
89
views
Testing -t STDIN vs -t <STDIN>
I'm writing an executable perl script, let's call it SCRIPT, that takes the output from another command executed from the command line and does something with that output.
For example
$ diff fileA ...
1
vote
0
answers
39
views
Library libuv expecting stdin, stout, stderr to be open, but for the daemons we should close the stdin and stdout as a standard practice
For the daemon processes, it is a standard practice to flcose(stdin); fclose(stdout);, same is there in the application code, and then we are trying to use dnsutility /usr/bin/host to resolve host ...
1
vote
1
answer
40
views
Why my gdb can't read the file by stdin? (very weird)
This is t.c, I use gcc t.c -o t -m32 -g to compile it:
#include <stdio.h>
int main() {
char buffer[100];
printf("Please enter a string: ");
scanf("%99s", buffer);
...
0
votes
0
answers
24
views
Why does `os.execl` interfere with `stdin` on Windows? [duplicate]
My minimal example is null.py:
import os, sys
os.execl(sys.executable, sys.executable)
I would have thought that python null.py would be pretty much the same as running python, which is the case on ...
3
votes
2
answers
134
views
Rationale behind declaring FILE * volatile to stdin in C
I wonder what reason might be to declare FILE *volatile fp as volatile pointer:
int main(int argc, char **argv) {
int gc;
fe_Object *obj;
FILE *volatile fp = stdin;
fe_Context *ctx = fe_open(...
0
votes
0
answers
63
views
How can I get this STDIN to work in GAS Assembler running on Linux?
I am new to Assembler and am currently reading a book about it by Jonathan Bartlett called 'Learn to Program with Assembly'. On pages 160-1 he gives the following sample program to demonstrate the use ...
0
votes
0
answers
49
views
asio::stream_descriptor for async read from stdin in raw mode crashes
I want to poll stdin asynchronously for terminal keyboard events, hence the following
/* class tui contains a member 'stdin_' of type 'asio::stream_descriptor',
initialized as such : stdin_{...
0
votes
0
answers
18
views
Send SSH input when output string is detected on windows from python
My company requires a passcode when SSHing to a server:
ssh myserver
Enter a passcode or select one of the following options:
Passcode:
I want call SSH in the background from a GUI so want to detect ...
7
votes
7
answers
285
views
gawk hangs when using a regex for RS combined with reading a continuous stream from stdin
I'm streaming data using netcat and piping the output to gawk. Here is an example byte sequence that gawk will receive:
=AAAA;=BBBB;;CCCC==DDDD;
The data includes nearly any arbitrary characters, but ...
0
votes
1
answer
24
views
undetectable Dart-Input in Visual Code Studio
I made a script in in Visual Studio Code using Dart that grabs the user's input.
The problem is, that if I enter something in the input line in vscode, which is located below the debug console and ...
0
votes
0
answers
57
views
Break the loop if stdin has value
I can not stop the loop if there is not a gap in data send via UART.
If there is gap in data it listens to the command but does not read the UART data anymore.
I would like to
I read data on UART and ...
1
vote
1
answer
78
views
How do I read all keys pressed in nim since the last call to a function, without needing to press enter
I need to read keys from stdin without blocking, and without only recieving them when a newline is pressed. The way i would like it be formatted is a sequence, where each item is a keypress or ascii ...
0
votes
0
answers
38
views
How do I know when a program is waiting for an input and then give the input through Python?
Sorry, this might look very stupid but I have a console C++ program and I need to pass input through Python. It is unexpected when this C++ program waits for an input and so I hoped I could have done ...
-1
votes
1
answer
58
views
Wrapping os.Stdin with an io.TeeReader breaks the tty
Context: I am trying to write a small tool in Golang, which spawns a vim editor and tries to record all the keystrokes input by the user.
package main
import (
"bufio"
"fmt&...
0
votes
0
answers
14
views
Console screen import/export error when using freopen
Can anyone tell me that when using freopen, sometimes when I call new functions using input and output commands on the console screen, it doesn't work? When running, it still works and still processes ...
0
votes
0
answers
27
views
Removing [stdin] keypress listener (or going around) from 3rd party app within plugin/extension (Vitest in this case)
I am writing Vitest reporter, when running tests in watch mode there is an active listener on keypress event on stdin. I want to have my own handling of user interaction, and this one pretty ...
0
votes
0
answers
25
views
Building a menu with inputs from serial port on a Pi Pico
After getting the first input, is not following the normal logic to continue waiting for the input and directly return an error.
1.Checking if there is any data on the stdin with readline() function ...
1
vote
1
answer
85
views
How can I read from neovim's stdin, using rust?
I'm pretty new to rust and I thought I could get some help here.
I'm trying to follow a guide about making LSPs from TJ DeVries, he is coding it in Go but I'm trying to follow along in Rust. I'm stuck ...
0
votes
1
answer
53
views
Bash - Log timestamp of the moment data was received on stdin, coming from a pipe
I have an application that outputs to stdout from time to time - random intervals, random durations of outputting before going silent again. Its output (binary data) is captured into a file.
I want to ...
0
votes
0
answers
47
views
getline() in C is not receiving input
I am trying to build a simple shell and im having a huge problem with receiving input from the stdin.
For whatever reason when i call getline(), the program gets stuck there and it can't progress.
...
-1
votes
1
answer
90
views
C# code, SendKeys.Send gets "Access denied..." error occasionally [duplicate]
I have a C# code, in which I need to run a very old vendor binary to ASCII conversion program, here is relevant part of my code:
C# code with SendKeys.Send "Access denied..."
These codes are ...
0
votes
1
answer
46
views
How to properly escape/quote the output so it's treated as an escaped input? [duplicate]
I've been trying to create a set of aliases or functions, that I can use in conjunction with file operating commands.
The idea is to have 1, 2, 3 functions/aliases that will return latest, second-to-...
0
votes
0
answers
36
views
Read a single char value to stdin without pressing enter on keybard in C in mac os [duplicate]
I am using mac os with xcode-select version 2406
I am trying to find a way to Read a char value to STDIN without pressing enter or return key on keyboard in C.
I know on windows we have getch function ...
1
vote
1
answer
72
views
Piping input into running Python script
Maybe this is the wrong approach, so feel free to redirect.
I am trying to asynchronously pipe input into a python script. The idea is that I have a background Python script do some long initial setup ...
3
votes
1
answer
271
views
Reading and Writing more than 4096 bytes to and from STDIN [closed]
I'm trying to implement a here document like the one used in bash (in C), but I noticed that I can't give it a line that's longer than 4096 bytes, I looked it up and It was because of the max size of ...
0
votes
0
answers
34
views
How to read piped input and use Console.ReadLine() in the same C# program?
I am trying to create a program that must accept piped input, and be able to request more input from the user afterwards. The problem is that after I read the piped input, I can no longer use Console....
2
votes
0
answers
40
views
Writes to child subprocess.Popen.stdin don't work from within process group?
From within a Python script, I'm launching an executable in a subprocess (for anyone interested: it's the terraria server).
# script.py
server_process = subprocess.Popen("my_executable arg1 arg2&...
4
votes
2
answers
537
views
How can I read a single line user input with Bun.js?
Bun.js has a useful native API to read periodical user input:
const prompt = "Type something: ";
process.stdout.write(prompt);
for await (const line of console) {
console.log(`You typed: ${...
1
vote
1
answer
117
views
Communicating Java and Python processes freeze after a while when using readline() but not input()
I have a Java program that needs to process a long series of input strings. To do this it goes through each string, passes it to a Process (a Python script), gets the result from the Process's ...
0
votes
1
answer
55
views
Redirecting stdout with execvp
This code basically a small part of the binary tree with nodes being processes, and it should traverse the tree inorder way passing num1 to left subtree etc. This one just creates a left child and ...
0
votes
0
answers
103
views
tar extract zip archive from file or STDIN - discrepancy
Training to download and extract archive (zip archive, created by 7z) by
curl --output - "https://host.com/archive.zip" | tar -f - -C %dest_dir%
but archive extract is incomplete. Some ...
0
votes
2
answers
224
views
Why is STDIN open by default for programs running in SystemD?
I have an if-statement at the top of a C main method, which checks if STDIN is open. If it is open, the program prints an error and exits. This is mainly for documentation reasons. I don't want ...
0
votes
0
answers
69
views
Is it possible to listen for console input from a C# Windows Application?
I have a .NET Core 3.0 Windows application that was interfacing with Chrome native-messaging stdin, however after .NET 8 migration, the application no longer has console stdin access. (Note: it was ...
0
votes
1
answer
55
views
Executing sed via execvp makes other pipes blocked
I am playing around with fork/pipe/dup/execvp concepts and came out with a little problem:
I made a test main to execute sort and manually send some numbers via pipe bound to STDIN and it works as ...
0
votes
0
answers
70
views
stdin file descriptor never ready on POLLIN event
I have a C source code that I intend to port from Linux to Windows. After updating the 'poll' function to 'WSAPoll,' I notice that 'revents' on 'stdin' never becomes ready, causing 'WSAPoll' to block ...
1
vote
1
answer
112
views
Exit inner loop only when EOF (Ctrl+D) is given via standard input
My program has a main while loop as the main logic, with an inner while loop for running the logic of the "command function". When inside the inner while loop, I want EOF (Ctrl + D) to exit ...
1
vote
2
answers
758
views
Difference to get string with gets and fgets in C
My question is, what is the difference between these two pieces of code.
1)
#include <stdio.h>
#include <stdlib.h>
#define SIZE 7
int main()
{
int strSize;
char tim[SIZE];
...
0
votes
1
answer
38
views
Calling bash from python subprocess maintaining context, returning results and printing to screen
I have a function that sends a statement to bash. It prints the output in real time to the console and also returns the value. It works flawlessly and looks like this:
def call_in_bash(statement):
...
0
votes
1
answer
137
views
Input, left arrow key - Rust
I wrote this code for create an user input.
std::io::stdout().flush().expect("Failed to flush stdout");
std::io::stdin().read_line(stdin_buffer).expect("Failed to read from stdin");...
2
votes
0
answers
71
views
Read from stdin, but only while socket is connected
I'm trying to build a simple Rust in-terminal TCP chat program.
I want to read user input from stdin, but only while the connection is still alive.
Specifically I want to avoid the situation where you ...
0
votes
1
answer
79
views
How to write a BASH command in C which use stdin and stdout
I want to write a programme where I compile a C programme, and save it where BASH recognises programmes are (/usr/bin or somewhere).
For usage I want to run in the terminal
$ c_programme <...
0
votes
0
answers
57
views
C# start python process which listens to StandardInput
I'm using Process.start() in python to start a python script. In general this works, but I have a problem concerning the performance when starting the python script.
The process is as follows:
C# ...
2
votes
1
answer
393
views
How can I read more than 4096 bytes from stdin, copy-pasted to a terminal on Linux?
I have this code:
import sys
binfile = "data.hex"
print("Paste ascii encoded data.")
line = sys.stdin.readline()
b = bytes.fromhex(line)
with open(binfile, "wb") as fp:...