Все вопросы: [stdin]

82 вопросов

похожие теги:
3
голосов
3ответов
1888 просмотров

Как отправить backspace с помощью sendmessage (C #) в cmd.exe

Я пытаюсь отправить нажатия клавиш на cmd.exe, который я запускаю из своего приложения.При этом я могу отправить все символы клавиатуры, но если я попытаюсь отправить Backspace, это не сработает.Ниже приведен фрагмент кода для отправки сообщения в cmd.exe: SendMessage((int)shell.MainWindowHan...

1
голосов
5ответов
410 просмотров

Я пытаюсь разделить строку по разделителю, но не получается, почему?

Я написал ниже код для построчного чтения из stdin ex. city = Бостон; city = Нью-Йорк; city = Чикаго \ n , а затем разделите каждую строку символом ';'разделитель и распечатать каждую запись. Но почему-то указатель "записи" всегда возвращается нулевым.Почему? char del = ';'; ...

3
голосов
1ответов
5243 просмотров

python stdin eof

Как передать python eof на стандартный ввод вот мой код p = Popen(commd,stdout=PIPE,stderr=PIPE,stdin=PIPE) o = p.communicate(inputstring)[0] когда я запускаю команду в командной строке после ввода окна строки ввода, все еще ожидая, что Ctrl + Z завершит прием ввода. Как передать в ...

2
голосов
2ответов
664 просмотров

Почему эта программа дает сбой (иногда)?

#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 (...

3
голосов
1ответов
3281 просмотров

ncurses и блокировка stdin

У меня есть stdin в наборе select(), и я хочу брать строку из stdin всякий раз, когда пользователь вводит ее и нажимает Enter . Но select запускает stdin как готовый к чтению до нажатия Enter и, в редких случаях, до того, как что-либо будет напечатано вообще.Моя программа зависает на...

3
голосов
7ответов
6434 просмотров

Как использовать 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 не является каталогом

21
голосов
7ответов
35120 просмотров

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...

0
голосов
1ответов
1988 просмотров

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...

0
голосов
1ответов
2860 просмотров

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...

10
голосов
5ответов
7181 просмотров

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...

1
голосов
3ответов
579 просмотров

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.

6
голосов
4ответов
5421 просмотров

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...

0
голосов
1ответов
205 просмотров

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...

3
голосов
3ответов
923 просмотров

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 &&...

4
голосов
3ответов
7515 просмотров

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 ...

1494
голосов
22ответов
1679535 просмотров

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?

149
голосов
9ответов
50801 просмотров

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...

1
голосов
1ответов
2300 просмотров

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...

5
голосов
3ответов
1392 просмотров

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...

16
голосов
3ответов
16588 просмотров

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...

25
голосов
8ответов
50229 просмотров

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?

4
голосов
1ответов
1103 просмотров

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()....

119
голосов
6ответов
36394 просмотров

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...

2
голосов
4ответов
7741 просмотров

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 ...

10
голосов
2ответов
5082 просмотров

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);

9
голосов
2ответов
14492 просмотров

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...

4
голосов
5ответов
22433 просмотров

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...

5
голосов
7ответов
3820 просмотров

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...

0
голосов
2ответов
2012 просмотров

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 ...

85
голосов
4ответов
62380 просмотров

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...