Capturing stdin


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Capturing stdin
# 1  
Old 01-24-2008
Capturing stdin

Hi all,

Consider the following situation:
- you launch an compiled binary application from inside a unix shell which presents a text-based type user interface where you can input information ...
# echo "I am the $SHELL shell"
# I am the /bin/bash shell
# ./input
# ... imagine the binary application 'input' to present here and you type input ...

Now ... it would be straight forward to wrap the calling of the 'input' binary in a shell script which only does ./input. Everything would still work.
But ... is there a way to capture all the input that is going to the 'input' binary from inside this intermediary script, without of course influencing the correct working.
So as to actually log every character i'm typing into the binary ?

Greetz
# 2  
Old 01-24-2008
I don't understand it.
1. You wrote that this is a binary file - so comment lines #* are not allowed
2. You wrote some text that seems like a scripts comment because every line starts with #
What do you have as input?
Where you want to have the output?
# 3  
Old 01-24-2008
Yeah well,

Maybe it's a bit too advanced for you, but for those who do understand I actually found a way that does a bit too much but I got whay I needed.

Check out man pages for 'script'.

Greetz
# 4  
Old 01-24-2008
You got the answer as clear as the question was. That's it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

STDIN and STDOUT

Hallo, i have a script like: if ;then echo "OK" else echo "ERROR $2 is missing" fi; if ;then touch $2 fi; if ;then cat $1 | grep xy > $2 (1 Reply)
Discussion started by: eightball
1 Replies

2. UNIX for Dummies Questions & Answers

stdin redirection

Hello, my C application under unix runs in redirecting stdin to a file. Example:$appli1 <file1. This application waits often on a scanf(). But I would temporarely reassign stdin at the keyboard for waiting a user's answer. So I thought to add system("appli2"); in the code of appli1. In its... (4 Replies)
Discussion started by: cypleen
4 Replies

3. UNIX for Dummies Questions & Answers

redirection stdin

Bonjour, Mon application en C sous linux tourne en redirigeant stdin vers un fichier. Exemple; $appli1 <file1. PB: Je voudrais temporairement redonner la main au user sur le clavier. Alors je pensais ajouter system("appli2"); dans appli1. Dans son main() , appli2() fait seulement un... (1 Reply)
Discussion started by: cypleen
1 Replies

4. UNIX for Dummies Questions & Answers

How to write to stdin of another program (program A -> [stdin]program B)

Hi, Program A: uses pipe() I am able to read the stdout of PROGAM B (stdout got through system() command) into PROGRAM A using: * child -> dup2(fd, STDOUT_FILENO); -> execl("/path/PROGRAM B", "PROGRAM B", NULL); * parent -> char line; -> read(fd, line, 100); Question: ---------... (3 Replies)
Discussion started by: vvaidyan
3 Replies

5. Programming

How to write to stdin of another program (program A -> [stdin]program B)

Hi, Program A: uses pipe() I am able to read the stdout of PROGAM B (stdout got through system() command) into PROGRAM A using: * child -> dup2(fd, STDOUT_FILENO); -> execl("/path/PROGRAM B", "PROGRAM B", NULL); * parent -> char line; -> read(fd, line, 100); Question: ---------... (1 Reply)
Discussion started by: vvaidyan
1 Replies

6. Shell Programming and Scripting

Redirecting to stdin

Hi, I'm having trouble with my script. I have to select different choices without any interaction from a menu that looks like : a - xxxxxxxxxxxxxx b - xxxxxxxxxxxxxx c - xxxxxxxxxxxxxx d - xxxxxxxxxxxxxx I tried things like : echo "a" >&0 read < echo "a" but none worked. Any... (4 Replies)
Discussion started by: flame_eagle
4 Replies

7. Shell Programming and Scripting

redirect STDIN

can you redirect STDIN with command arguments? I have tried this approach: # ./script -option <argument1> <argument2> 0<$2 # $2: ambiguous redirect Is this possible? (4 Replies)
Discussion started by: prkfriryce
4 Replies

8. Shell Programming and Scripting

echo with stdin

Why doesnt echo output the contents of the file abc.txt as shown below ? chid@athena:~$ cat abc.txt sssss chid@athena:~$ echo < abc.txt chid@athena:~$ (6 Replies)
Discussion started by: systemsb
6 Replies

9. Shell Programming and Scripting

redirection stdin

hello all, I need to create a password change utility for a database. I need to gather at the command line the username, password and database sid. I have the program currently doing this. What I would like to do is not have the new password appear on the screen when I do my read command.... (2 Replies)
Discussion started by: whited05
2 Replies

10. Programming

stdin

hi, how does a program know whether some data are available from stdin? I would like to make a program which could read its data from stdin and _if_there_is_nothing_at_stdin_ from a file which name is given as an argument. If there is nothing in stdin and no filename is given as argument,... (2 Replies)
Discussion started by: marquis
2 Replies
Login or Register to Ask a Question