stdin

Piping EOF problems with stdio and C++/Python

I got some problems with EOF and stdio in a communication pipeline between a python process and a C++ program. I have no idea what I am doing wrong. When I see an EOF in my program I clear the stdin and next round I try to read in a new line. The problem is: for some reason the getline function immediatly (from the second run always, the...

How could I redirect stdin (istream) in wxWidgets?

Hi, I'm trying to figure out how to redirect istream to wxwidgets. I was able to accomplish redirecting ostream, here's how (so you know what I mean): wxTextCtrl* stdoutctrl = new wxTextCtrl(...); wxStreamToTextRedirector redirect(stdoutctrl); //Redirect ostream std::cout<<"stdout -- does this work?"<<std::endl; //It worked. I'...

Python: UnicodeEncodeError when reading from stdin

When running a Python program that reads from stdin, I get the following error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 320: ordinal not in range(128) How can I fix it? Note: The error occurs internal to antlr and the line looks like that: self.strdata = unicode(data) Since I don't want to modi...

How do i pass null into stdin like this perl code?

This is my question and apparently this is the answer. Turns out it was a buffer problem (solution in the accepted answer of my ffmpeg link) not stdin. I found you can stdout to null by writing > NUL in command prompt so i tried writing < NUL at the end of my argument. No luck. How do i pass in null or do something with the IO locks li...

Pipe ffmpeg to oggenc(2) with .NET

I am trying to encode ogg files at -q 6/192k. ffmpeg doesnt seem to be listenting to my command ffmpeg -i blah -acodec vorbis -ab 192k -y out.ogg So i would like to use the recommended ogg encoder. It says the input must be wav or similar. I would like to pipe a wav from ffmpeg to ogg. However not only am i unsure if oggenc2 will acc...

How can I read piped input in Perl on Windows?

I am trying to create something in Perl that is basically like the Unix tee command. I'm trying to read each line of STDIN, run a substitution on it, and print it. (And eventually, also print it to a file.) This works if I'm using console input, but if I try to pipe input to the command it doesn't do anything. Here's a simple example: ...

C++ cin problems. not capturing input from user

I have the following method which is not capturing anything from the user.If I input New Band for the artist name, it only captures "New" and it lefts out "Band". If I use cin.getline() instead nothing is captured. Any ideas how to fix this? char* artist = new char [256]; char * getArtist() { cout << "Enter Artist of CD: " << endl;...

How to read STDIN into string variable until EOF in C?

Hi, im getting "Bus Error" trying to read stdin into a char* variable. I just want to read whole stuff coming over stdin and put it first into a variable, then continue working on the variable. My Code is as follows: char* content; char* c; while( scanf( "%c", c)) { strcat( content, c); } fprintf( stdout, "Size: %d", strlen( content...

How to send EOF to stdin in paramiko?

I would like to execute some program through ssh and redirect its input from a file. The behaviour of the following code: channel.exec_command('cat') with open('mumu', 'r') as f: text = f.read() nbytes = 0 while nbytes < len(text): sent = channel.send(text[nbytes:]) if sent == 0: break nby...

how to redirect stdin to java Runtime.exec ?

I want to execute some sql scripts using Java's Runtime.exec method. I intend to invoke mysql.exe / mysql.sh and redirect the script file to this process. From the command prompt I can run the command <mysqInstallDir\/bin\mysql.exe -u <userName> -p <password> < scripts\create_tables.sql I can invoke mysql.exe using Runtime.exec but ...

How do I check if my program has data piped into it.

Im writing a program that should read input via stdin, so I have the following contruct. FILE *fp=stdin; But this just hangs if the user hasn't piped anything into the program, how can I check if the user is actually piping data into my program like gunzip -c file.gz |./a.out #should work ./a.out #should exit program with nice msg. ...

Capturing the input stream as a user types

I am working on a C++ based command line tool and I want to capture the user's keystrokes in real-time without requiring them to hit Return to commit the input. I can't seem to find an iostream call to support this kind of behavior but I recall from my college years that it can be done. Can anyone point me in the right direction? ...

Can I make ungetc unblock a blocking fgetc call?

I would like to stuff an 'A' character back into stdin using ungetc on receipt of SIGUSR1. Imagine that I have a good reason for doing this. When calling foo(), the blocking read in stdin is not interrupted by the ungetc call on receipt of the signal. While I didn't expect this to work as is, I wonder if there is a way to achieve this...

Perl standard input with argument inside Bash

I want to have such pipe in bash #! /usr/bin/bash cut -f1,2 file1.txt | myperl.pl foo | sort -u Now in myperl.pl it has content like this my $argv = $ARG[0] || "foo"; while (<>) { chomp; if ($argv eq "foo") { # do something with $_ } else { # do another } } But why the Perl script can't recognize the parameter passed t...

Redirect stdin in C program to another process

I have a C program, and I'd like to have it filter all its input with tr. So, I'd like to start up tr as a child process, redirect my stdin to it, then capture tr's stdout and read from that. Edit: here's the code I have so far, which doesn't work. It segfaults instantly, but I don't understand why: #include <stdlib.h> #include <stdio....

select always returns -1 while trying to read from socket and stdin

Hello I have the following code implemented on C++(Linux) to check on my listening socket and stdin using select. select however keeps returning -1 no matter what I try to do! What's wrong with that code :s I will appreciate any help. Thanks highsock = m_sock; //listening socket memset((char *) &connectlist, 0, sizeof(connectlist)); m...

How to make a Java class listening for events on the "stdout" of a C program

public static void main(String[] args) { try { String line; InputStream stdout = null; OutputStream stdin = null; Process process = Runtime.getRuntime().exec("test.exe"); stdout = process.getInputStream (); stdin = process.getOutputStream (); ...

Stdin to powershell script

I have a service running that can invoke an external process to modify a text stream before it is returned to the service. The text stream is handed from the service to the external process on stdout and the modified result is read from the service on stdin. The external process (command) can in other words be used as a text "filter". I ...

Send stdin to a process from windows command prompt

In Windows I have console programs that run in the background with console hidden. Is there anyway to direct input to the programs console? I want to be able to do something like: echo Y| *the_running_process_here* to send Y to the process' stdin. ...

Linux C select: piping echo to input works, but reading from keyboard doesn't?

Hi all, I am trying to understand http://beej.us/guide/bgnet/examples/select.c (included below for reference). I am doing this: :~$ cat /etc/issue Ubuntu 10.04 LTS \n \l :~$ gcc --version gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3 :~$ wget http://beej.us/guide/bgnet/examples/select.c :~$ gcc select.c -o select :~$ echo "ff" | ./select...