Questions tagged [stdin]
Standard input (stdin, file descriptor 0) is the input stream to a program.
3,884
questions
2
votes
2
answers
112
views
Bash - Check if the standard input contains anything
I know this question has been asked several times but it seems ineffective in my case.
[[ ! -t 0 ]] = Does standard input contains anything?
This command:
echo 'Hello world' | [[ ! -t 0 ]]
echo $?
...
0
votes
2
answers
52
views
Who should be responsible for "program startup with three std streams opened"?
I'm working on my study purpose OS kernel, now I have a confusion about creating time of standard streams.
The famous "APUE" said that "By convention, UNIX System shells associate file ...
0
votes
1
answer
18
views
How can I compile a program using Clang from standard input?
I have a program coming from standard input. I would like to compile it. Is this possible and if so, how can I do this?
-1
votes
0
answers
46
views
fgets issues in another loop [closed]
I have an assignment to write a program that calculates typing speed, but it seems that I cannot enter the second while loop using the fgets function. Why is this, and how can I fix it? This has been ...
-1
votes
0
answers
94
views
Weird behavior when using fscanf() and structs in C [duplicate]
NOTE: I know "authenticating" users the way I'm doing is absurdly insecure but I just wanted to put into practice my knowledge on structs and file I/O in C.
OTHER NOTE: I'm compiling with ...
0
votes
0
answers
11
views
Object 'Kind' is missing error while running skaffold dev command
after running skaffold dev command this error i am getting, i am using docker desktop in windos and running this command in linux enviorment wsl subsystem docker and kubernents are working fine i ...
1
vote
1
answer
31
views
How can I make a child process's stdin inherited and piped?
I want to create a child process that will take normal input from the parent stdin. but at the same time i want to send signals through its stdin (ctrl+c - 0x03 like xterm does).
Using the standard ...
1
vote
0
answers
77
views
How do I capture stdout and simulate stdin in a Haskell Tasty test?
My impure functions are defined as follows:
module HangmanImpure (HangmanImpure.getLine, HangmanImpure.putStr, HangmanImpure.putStrLn, HangmanImpure.strlen) where
import qualified System.IO as Sys
...
0
votes
2
answers
58
views
stdin is not being saved to file
I am trying to get a better understanding how stdin works and how to specifically work with it in Python.
I am trying to save whatever is received from stdin to a file. The file should have two lines
...
0
votes
0
answers
54
views
My simple python program does not execute the last line
I have a simple Firefox extension, I have pretty much figured out the Firefox side of things (JavaScript, DOM and starting the Python program).
To explain how everything is supposed to work:
A event ...
0
votes
0
answers
30
views
Write into stdin, read from stdout Subprocess/Process in Glib/GTK Vala
I have a test bash/sh script. It simply shows a question and reads answer from console, then it shows output:
#!/bin/bash
# Ask the user for their name
echo Hello, who am I talking to?
read varname
...
-1
votes
1
answer
26
views
Standard input in dale programming language
How can I get in dale the standard input to get data from any file? Thanks in advance.
I've already tried with the "gets" built-in functions. May be I've been doing something wrong.
I need ...
2
votes
1
answer
69
views
How can I read one byte from stdin in Dyalog APL?
I’m trying to make a terminal user interface in Dyalog APL and need a way to read a single byte of user input from stdin. How can I do this? In Python for example, you can use sys.stdin.read(1).
I’ve ...
-1
votes
2
answers
76
views
C fgets string length not limited to input
I'm confused how even though the char array mystring I provided can only be upto 5 characters long, the length can exceed 5 if fgets is supplied with a larger limit.
#include <stdio.h>
#include &...
1
vote
1
answer
20
views
Can I access FFPlay.exe's STDIN in order to emulate a 'q' keypress?
I am writing a Win32 program that launches ffplay.exe. I would like to have my program send a quit message ('q') but cannot get ffplay to respond. I am using CreatePipe() to initialize read/write ...
0
votes
1
answer
47
views
How do I post a character to a console program's STDIN?
I am writing a Win32 program in C that launches a console application which can be stopped by pressing Q on the keyboard. Pressing Q on the keyboard makes the console application stop; I just want to ...
1
vote
2
answers
40
views
Can a non-interactive tclsh be made interactive?
When developing Tcl code, I find the interactive facilities of tclsh very useful, and I'll often launch tclsh interactively, source code from files, and continue to run and debug from there.
What I'm ...
0
votes
0
answers
25
views
Docker py Stdin not working inside container
I'm trying to make an API in python that uses dockerpy to execute some code given by a user.
So far, i'm able to execute simple code that doesn't require to interact with stdin, such as print("...
1
vote
0
answers
36
views
Redirect sys.stdin and sys.stdout [duplicate]
I'm trying to redirect stdin and stdout. My first attempt I tried this code:
from sys import stdin, stdout
stdin = open('in.txt','r')
stdout = open('out.txt','w')
for line in stdin:
print(line)
...
1
vote
0
answers
60
views
Is there a way to git grep stdin?
I want to use git grep with input taken from stdin. There is an option --no-index but according to documentation it only allows to grep files in the current directory:
--no-index
Search files in the ...
0
votes
1
answer
83
views
How to get Pipe and Here String in Python?
When calling a Python script via
echo foobar | python myscript.py <<< test123
How can I get both strings (the "foobar" and "test123") in the Python script?
When trying
...
1
vote
1
answer
79
views
Cannot turn off line buffering in C
So, I'm working on a big project, and it requires the stdin and stdout buffers to be disabled so that input and output are processed immediately. However, when I try to do that using setbuf or setvbuf,...
1
vote
1
answer
48
views
Why grep ignores the first line of "python3 -m http.server" output?
For some reason grep will not print the first line of the output of the command:
python3 -m http.server
python3 -m http.server
# prints: Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
...
-1
votes
1
answer
69
views
One-way communication in python
For the last day I've been trying to get some one-way continuous communication between two python scripts as an exercise for a bigger project. However, subprocess.communicate only allows a one-time ...
1
vote
1
answer
117
views
How to check if input is empty?
How to check if user inputs nothing and presses enter only? If that happens then error message and code stops. In C language.
I tried == '\n' and " " but nothing works :(
int main() {
...
0
votes
1
answer
34
views
Python Popen Subprocess - interacting with executable not possible until stdin is closed
I am trying to interact with a Commandline Executable, but I am stucked.
I would like to print out every line, the .exe is producing to stdout.
Until I get "condition" in a line -> then ...
0
votes
1
answer
71
views
How to connect the stdin streams of parent and child processes?
I have problem to write stdin in deno version 1.37.0 (release, x86_64-pc-windows-msvc). I search in documentation, google, try the code and not work. I found related code in https://github.com/...
-3
votes
1
answer
73
views
this code prints nothing on intelliJ idea, it didn't even takes user input or anything
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
// Write your code here.
...
1
vote
0
answers
65
views
Pipe Input Error when Processing MOV Files
I'm working on a project in Go where I'm trying to process video files using ffmpeg through pipes. However, I'm encountering issues when I try to use a pipe for the input stream.
Here's a snippet of ...
0
votes
1
answer
122
views
x86_64 nasm read syscall isn't null-terminated
x86_64 nasm read syscall isn't null-terminated
New to assembly. In fact this is my first hello world program.
OS: Arch Linux (64-bit)
Logic
I have three functions. strlen, stdin and stdout.
strlen:
...
0
votes
0
answers
25
views
Is there realised solutions to unpack `stdin` as arguments? [duplicate]
I would like to have the option to pass positional arguments via stdin. I have written my own argparse.Action subclass to overwhelm the problem, that does work, but it would be desirable to evade ...
4
votes
1
answer
79
views
Why does wc output different padding spaces depending on how stdin is connected?
See the following two commands with output:
$ wc < myfile.txt
4 4 34
$ cat myfile.txt | wc
4 4 34
My understanding is that these two both connect the stdin of the wc process ...
0
votes
1
answer
31
views
Why isn't my output maintaining integrity after a pipe to a program that takes input from stdin?
My output gets corrupted when I try to pipe some output to another command in the shell. This doesn't happen when I execute the executable alone, or redirect its output to a program that doesn't care.
...
0
votes
0
answers
41
views
why the subprocess.run with ssh closed parent process' stdin pipe
I have 2 python scripts:
# foo.py
import time
import subprocess
from multiprocessing import Process
def foo():
subprocess.run(["ssh", "localhost", "sleep", "10&...
0
votes
0
answers
120
views
Golang Non Blocking os.Stdin Read for Cmd
cmd := exec.Command("env")
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
This works well regardless env command doesn't relay on reading from stdin
Yet for
cmd := exec.Command("env")...
0
votes
1
answer
50
views
How to quickly skip a certain piece of input in C
For the project I'm building for one of my courses (first time doing this, please don't bash me if I'm missing some basic things), which is basically about handling a data structure, my code should be ...
0
votes
1
answer
86
views
In Jenkins pipeline how to pass a string that is read by a shell script from the stdin
I have a jenkins pipeline. How can I "pass" a string as stdin to a shell script?
def getStatusJson() {
if (this.statusJson == null)
this.statusJson = slowHttpRequest()
}
...
0
votes
2
answers
44
views
Standard input problem with typescript node
I needed to create a script that takes from the standard input, and waits until it does not get the user input, and then goes on according to what the user did. This is the code I have written so far:
...
2
votes
1
answer
62
views
How to read zipfile from stdin
I'm trying to solve reading a zipfile from stdin in python, but I keep getting issues. What I want is to be able to run cat test.xlsx | python3 test.py and create a valid zipfile.ZipFile object ...
1
vote
2
answers
51
views
Equivalent of Unix/Linux tail command for Powershell - that supports pipes?
I'm aware that Get-Content has a -Tail parameter, but as far as I can tell, there's simply no way to get it to accept piped input.
So how do I get something like this to work? I just want to be able ...
0
votes
1
answer
82
views
How the python interpreter receives and outputs data?
What happens when I write print('Something')?
Does the interpreter work directly with the system I / O means, or does it use some kind of system API, which gives information that something needs to be ...
0
votes
1
answer
26
views
Is there a way to get the command ran to get stdin output in python?
So I've found a way to read from stdin in python, which is as follows:
if not sys.stdin.isatty():
stdin = sys.stdin.read()
but for a statement like this,
echo Hello | program.py
I only get stdin ...
0
votes
0
answers
24
views
Send stdin into docker container
Send stdin into docker container in docker-py
stdin type string
In container, there is a a.py file in /app
print(input())
In out of container, I use:
import docker
client = docker.from_env()
...
1
vote
2
answers
293
views
trying to get username and password frrom stdin and remove \r\n
I am looking at examples but they all work with only one line piped/input into my rust program, but I need 2 lines or more as Strings so I can remove the \r\n or \n or \r and the last . line, so ...
1
vote
0
answers
31
views
Unable to push newline to nodejs child process
I'm trying to run a command on my terraria server via nodejs
const { spawn } = require("child_process");
const server = spawn(
"dotnet",
[
"tModLoader.dll",
&...
2
votes
2
answers
169
views
In haskell, how can I interact with stdin of an `IO ()`?
This shows the spirit of what I want to do and it almost works (just not within within my current nix setup):
echo :: IO ()
echo = getLine >>= putStrLn
testEcho :: IO ()
testEcho = do
(Just ...
0
votes
2
answers
43
views
Feed private key to pageant via STDIN
Is there a way in Windows to trick or simulate the file, made from other command output?
What I am looking for is the following bash equivalent, but for Windows and pageant:
sops --decrypt "${f}&...
2
votes
4
answers
107
views
Is there a way to compare multiple strings in C? [ I input them through fgets() ]
int Distance() {
char from[40], to[40];
double val;
double result;
printf("Enter what you want to convert from: ");
fflush(stdin);
fgets(from, 40, stdin);
...
0
votes
0
answers
48
views
How to stop reading to stdin while using sleep() - Python
I am trying to make a command-line-app/game and followed this website to get the basic functionality making use of tty.setraw(sys.stdin) and ANSI escape codes to draw to the terminal. The problem is, ...
1
vote
1
answer
52
views
How can I use the --stdin option with git-for-each-ref?
Recently, since git 2.41.0, a --stdin option has been added for the for-each-ref command. I tried using it to filter only certain refs but I failed and got this error message instead:
fatal: unknown ...