Все вопросы: [stdin]
82 вопросов
Как отправить backspace с помощью sendmessage (C #) в cmd.exe
Я пытаюсь отправить нажатия клавиш на cmd.exe, который я запускаю из своего приложения.При этом я могу отправить все символы клавиатуры, но если я попытаюсь отправить Backspace, это не сработает.Ниже приведен фрагмент кода для отправки сообщения в cmd.exe: SendMessage((int)shell.MainWindowHan...
Я пытаюсь разделить строку по разделителю, но не получается, почему?
Я написал ниже код для построчного чтения из stdin ex. city = Бостон; city = Нью-Йорк; city = Чикаго \ n , а затем разделите каждую строку символом ';'разделитель и распечатать каждую запись. Но почему-то указатель "записи" всегда возвращается нулевым.Почему? char del = ';'; ...
python stdin eof
Как передать python eof на стандартный ввод вот мой код p = Popen(commd,stdout=PIPE,stderr=PIPE,stdin=PIPE) o = p.communicate(inputstring)[0] когда я запускаю команду в командной строке после ввода окна строки ввода, все еще ожидая, что Ctrl + Z завершит прием ввода. Как передать в ...
Почему эта программа дает сбой (иногда)?
#include <cstdio> #include <QtCore/QProcess> int main (int argc, char** argv) { // if we remove 3 following lines, the problem described below doesn't exists!! QProcess process; process.start ("asdqwe"); // doesn't matter what we try to execute here. process.waitForStarted (...
ncurses и блокировка stdin
У меня есть stdin в наборе select(), и я хочу брать строку из stdin всякий раз, когда пользователь вводит ее и нажимает Enter . Но select запускает stdin как готовый к чтению до нажатия Enter и, в редких случаях, до того, как что-либо будет напечатано вообще.Моя программа зависает на...
Как использовать cp из стандартного ввода?
Примечание: # cat /tmp/foo - обычный файл /lib/a.lib /lib/b.lib /lib/c.lib /lib/d.lib cat /tmp/foo | xargs cp /tmp/fred cp: target /lib/d.lib не является каталогом
C read binary stdin
I'm trying to build an instruction pipeline simulator and I'm having a lot of trouble getting started. What I need to do is read binary from stdin, and then store it in memory somehow while I manipulate the data. I need to read in chunks of exactly 32 bits one after the other. How do I read in c...
How do I go about Flushing STDIN here?
I have a function (in C) that gets input from the user, (using scanf) stores it in an unsigned int, and returns the input to other functions that handle it: unsigned int input(void) { unsigned int uin; scanf("%u", &uin); return val; } I was wondering, being as I ought to flush...
Java: dealing properly with pipes as stdin
I get a weird error ("The process tried to write to a nonexistent pipe.") if I stop reading from piped input, from a program that works fine for non-piped input. How can I avoid causing this error? code: package com.example.test; import java.io.BufferedReader; import java.io.IOException; impor...
How to check if stdin is still opened without blocking?
I need my program written in pure C to stop execution when stdin is closed. There is indefinite work done in program main cycle, and there is no way I can use blocking checks (like getc()) there (no data is supposed to arrive on stdin - it just stays opened for unknown time). I intend to use de...
What is the simplest way to execute arbitrary process with stdin, stdout forwarded to a socket?
I'm interested in two situations: How to do it from C++? How to do it from system's shell? Answers for Linux, Windows and OSX are welcome.
Java+Eclipse: how do you debug a java program that is receiving piped/redirected stdin?
I'm using Eclipse to develop a Java program, and figured I'd add an option to my program to parse stdin if there are no arguments. (otherwise it parses a file) I am having problems if I execute "somecommand | java -jar myjar.jar" and went to debug... then realized I don't know how to start a pro...
CreateProcessWithLoginW - Redirecting STDOUT
What I would like is to have the process start but have the input and output all be in the same console. if(CreateProcessWithLogonW(user,domain, pass, LOGON_WITH_PROFILE, NULL, cmd, 0, 0, 0, &sa, &pe)) { printf("[~] Process spawned with PID %X\n", pe.dwProcessId); } else { print...
Using getchar() after read()
c for keyboard capture. Following code finds when an arrow key/ esc is pressed. At the same time I want to read whole words that user inputs and these should be shown on stdout as well. char pp = 0; char p = 0; while( (i = read(0, &c, 1)) == 1) { if (pp == 033 && p == 0133 &&...
Binary stdin and stdout
I'm looking to write a pair of utilities that read in a newline separated list of integers on stdin and output their binary (4 byte) equivalent to stdout, and vice versa. My first thought was a simple bash/linux command that would do this, but I was unable to find one. My second thought was to ...
How do you read from stdin?
I'm trying to do some of the code golf challenges, but they all require the input to be taken from stdin. How do I get that in Python?
How to trick an application into thinking its stdout is a terminal, not a pipe
I'm trying to do the opposite of "Detect if stdin is a terminal or pipe?". I'm running an application that's changing its output format because it detects a pipe on STDOUT, and I want it to think that it's an interactive terminal so that I get the same output when redirecting. I was thinking th...
Calling fgets() on popen() of 'ssh' is flushing the beginning of stdin of the calling process (ptty issue)
I have now whittled this down to a minimal test case. Thus far I have been able to determine that this is an issue related to pseudo-terminals which come about with the pipe of ssh. Adding the '-t -t' to the ssh call improved things, in that now, it takes a second call to fgets() to cause the i...
Temporary Input Redirection in Bash
I am looking for a way to dump input into my terminal from a file, but when EOF is reached I would like input returned back to my keyboard. Is there a way to do this with Bash (or any other commonly-available *nix shell)? Details: I am debugging a server program which executes a fork to start a...
How can I reinitialize Perl's STDIN/STDOUT/STDERR?
I have a Perl script which forks and daemonizes itself. It's run by cron, so in order to not leave a zombie around, I shut down STDIN,STDOUT, and STDERR: open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; open STDOUT, '>>/dev/null' or die "Can't write to /dev/null: $!"; open STDE...
How to make ssh receive the password from stdin
How can you make SSH read the password from stdin, which it doesn't do by default?
Win32: ReadFileEx() on STD_IN_HANDLE blocks, why?
I'm trying to use the Win32 API to make a sub-thread that reads from STD_INPUT_HANDLE and pushes the bytes it reads into a socket. Because I want to be able to shut down this thread safely when it's time to exit, I'm using ReadFileEx() and overlapped I/O instead of plain old blocking ReadFile()....
Detect if stdin is a terminal or pipe?
When I execute "python" from the terminal with no arguments it brings up the Python interactive shell. When I execute "cat | python" from the terminal it doesn't launch the interactive mode. Somehow, without getting any input, it has detected that it is connected to a pipe. How would I do a sim...
Not able to use 7-Zip to compress stdin and output with stdout?
I get the error "Not implemented". I want to compress a file using 7-Zip via stdin then take the data via stdout and do more conversions with my application. In the man page it shows this example: % echo foo | 7z a dummy -tgzip -si -so> /dev/null I am using Windows and C#. Results: 7-Zip ...
Can i put binary in stdin? C#
Related to this question encrypt binary with 7z without filenames? In C# how can i put binary in STDin? i was hoping the below would work but it doesnt. And it makes sense. So how do i push a byte[] array? new BinaryWriter(p.StandardInput.FormatProvider);
using QTextStream to read stdin in a non-blocking fashion
Using Qt, I'm attempting to read the contents of the stdin stream in a non-blocking fashion. I'm using the QSocketNotifier to alert me when the socket has recieved some new data. The setup for the notifier looks like this: QSocketNotifier *pNot = new QSocketNotifier(STDIN_FILENO, QSocketNotifier...
read() from stdin doesn't ignore newline
I am using the following conditional statement to read from standard input. if ((n = read(0,buf,sizeof(buf))) != 0) When inputting data from standard input, generally the user presses enter when done. But read() considers '\n' as input too in which case n = 1 and the conditional doesn't evalua...
How can I read the output from external commands in real time in Perl?
I have a few bash scripts I run, but they can take several hours to finish, during which time they spew out download speeds, ETAs and similar information. I need to capture this information in perl, but I am running into a problem, I cannot read the output line by line(unless I'm missing somethin...
Perl script to run a C executable with an argument while giving standard input through a file?
I want to run and executable ./runnable on argument input.afa. The standard input to this executable is through a file finalfile. I was earlier trying to do the same using a bash script, but that does not seem to work out. So I was wondering whether Perl provides such functionality. I know I can ...
How can I "intercept" Ctrl+C in a CLI application?
How can I intercept Ctrl+C (which normally would kill the process) in a CLI (command line interface) Java application? Does a multi-platform solution exist (Linux, Solaris, Windows)? I'm using Console's readLine(), but if necessary, I could use some other method to read characters from standard...