Hi All,
I wrote below code to readin line by line from stdin ex.
city=Boston;city=New York;city=Chicago\n
and then split each line by ';' delimiter and print each record.
But for some reason the "record" pointer comes back always null. Why?
char del = ';';
char input[BUFLEN];
while(fgets(input, BUFLEN, fp)) {
...
I am trying to send keystrokes to cmd.exe that I launch from my app. In doing so, I am able to send all the keyboard characters, but if I try to send Backspace, it doesnt seem to take effect. The following is the code snippet to send message to cmd.exe:
SendMessage((int)shell.MainWindowHandle, WM_KEYDOWN, ((int)e.KeyCode), 0);
SendMessa...
I've written a command line utility that uses getopt for parsing arguments given on the command line. I would also like to have a filename be an optional argument, such as it is in other utilities like grep, cut etc. So, I would like it to have the following usage
tool -d character -f integer [filename]
How can I implement the followi...
Is it possible to compress (create a compressed archive) data while reading from stdin on Linux.
...
Hi everybody,
I'm trying to send an arrow key via the stdin to the bash:
cat | /bin/bash
then i am typing "echo hi" => "hi" appears on the console (of course without the quotes)
then i press the arrow key up => ^[[A command not found appears
Is it possible to send an arrow key to an program via the stdin ?
The reason why i am asking...
System(); is able to call a program in PATH. How is it possible to send stdin read from e.g. a text field on a GUI to a command line program such as ftp, sftp ... with their own prompts?
System() waits for a program to quit, but ftp does not without user interaction. It's also not possible to create a batch file since it's read only one ...
Hi *
I need to automate an command line application. It asks the user to enter a password. All my approches to send the password via STDIN failed. Now I am trying to do this with an wrapper-programm using .NET.
I am starting the application creating a new process, setting the StartInfo-properties and then start the process:
Dim app_pa...
I have an interactive program that runs stdin and stdout.
I need to create wrapper that will send X to it's stdin, check that it prints Y and then
redirects wrapper's stdin and stdout to program's stdin and stdout just like program would be executed directly.
How to implement this ? X and Y can be hardcoded. Bash? Python?
Edit: I can't...
Hi, I'm writing in Microsoft Visual C++ and I'd like my program to either read from standard input or a file using the istream_iterator. Googling the internets hasn't shown how simple I think it must be. So for example, I can write this pretty easily and read from standard input:
#include <iostream>
#include <string>
#include <iterator>...
I have a file that I read from, it contains a bunch of lines each with a different number of integers, I'm having trouble splitting it up into a vector of a vector of ints.
This is my current code.
std::vector<int> read_line()
{
std::vector<int> ints;
int extract_int;
while((const char*)std::cin.peek() != "\n" && std::cin.p...
I'm very new to programming so I apologize in advance if my question is too silly.
#!/usr/bin/python2.6
import subprocess, time
p=subprocess.Popen(['cat'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
for i in 'abcd':
p.stdin.write(str.encode(i+'\n'))
output=p.stdout.readline()
print(output)
time.sleep(1...
Hi There,
Does anyone know how to read stdin using a custom Command in the Yii framework?
I am busy writing a script to process incoming mails through a php script but need functionality from within the Yii framework as well. By default Yii passes the command line arguments in a variable to your run() method when you extend the CCon...
Sorry if this is a naïve question, but let's say I have a Ruby program called processor.rb that begins with data = STDIN.read. If I invoke this program like this
cat textfile.txt | processor.rb
Does STDIN.read wait for cat to pipe the entire textfile.txt in? Or does it assign some indeterminate portion of textfile.txt to the data vari...
I have to capture the stdout in a program and write that into a file...so I created a pipe. In the parent process, I captured the stdout in the pipe using dup() and I need to get this into a file...so I did a dup() in the child to get the captured file descriptor into the stdin. Now, how do I write this stdin into a file using fwrite()?...
Ruby has constants and global variables for stdio.
Namely, the consts STDIN, STDOUT, STDERR, and their variable counterparts, $stdin, $stdout, $stderr.
I understand the difference between a constant and a variable. I know the constants are immutably set to the file descriptors at the moment the script was exec'd.
I also understand tha...
Hi,
I'm trying to read from stdin multiple times in a shell script, with no luck. The intention is to read a list of files first (which are read from the stdin pipe), and then read twice more to get two strings interactively. (What I'm trying to do is read a list of files to attach in an email, then the subject and finally the email b...
Hi,
I know everybody has told me to use fgets and not gets because of buffer overflow. However, I am a bit confused about the third parameter in fgets(). As I get it, fgets is dependent on:
char * fgets ( char * str, int num, FILE * stream );
char* str is the ptr to where my input will be stored.
num is the max number of characte...
This works quite nicely - just wondered if there are any improvements to shorten it ?
if (ARGV[0].nil?) then
input=$<
else
input=File.new(ARGV[0],"r");
end
...
# Do something with the input here, for example:
input.each_line do |line|
puts line
end
...
How I can use getchar() in a loop? Now I have...
for (p=0; p<n_players; p++) {
...
fflush(stdin);
getchar();
}
But it doesn't work... if n_players is 3, it execute getchar 2 times only at the end...
for (p=0; p<n_players; p++) {
blank_start();
ascii_art_title();
printf("%s, tocca a te...\n",player_info[p].play...
I'm trying to create a zip file from file contents which are being piped in, e.g.
mysql [params and query] | zip -q output.zip -
This writes the zip correctly, but when you open the zip, the file within it is called "-". Is there any way of specifying what the filename of the piped in data should be within the zip?
...