Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-03-2008, 12:25 PM   #1
LQ Newbie
Registered: Mar 2008
Posts: 2

Rep: Reputation: 0
send input to running program


Here's the deal. I have a program that I want to run. This program takes input from stdin at various times.

I want to be able to run this program but have another program, or preferably a shell sript, handle the job of sending input to this programs stdin. Basically, the program I am running is a kind of simulator. It will eventually run in an embedded system and it will get its input from another chip. The simulator allows me to test the code in linux but it's a pain in the butt having to keep sending the program the lines it requires as responses to the commands it sends out (all ascii text). I'd much rather be able to put together a couple scripts that run the program and then send it ascii strings at various times (when the program sends out a command, I want to be able to automatically answer this via a script).

This doesn't have to be smart at all. The script can be programmed to send responses at various times (i.e. wait 10 seconds then send response).

So far I can see how to pipe the output of a command to the input of another command or how to redirect stdout to a file but what I need to do is to have a script send input to stdin of another program.

That's it, thanks
Old 03-03-2008, 12:27 PM   #2
LQ Guru
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190Reputation: 1190
I think the feature you want is called a named pipe. I don't recall the details, but I think it is pretty easy. If you do a seach for "named pipe" I think you will find your answer.
Old 03-03-2008, 12:54 PM   #3
LQ Newbie
Registered: Mar 2008
Posts: 2

Original Poster
Rep: Reputation: 0
You are correct my friend, I had forgotten all about the fact that I could make my own named pipe to use.
Old 03-03-2008, 01:03 PM   #4
Registered: Dec 2007
Posts: 30

Rep: Reputation: 15
I'd suggest expect, its a shell that can simulate input when a certain match occurs. It can even hand over control to the user at certain points then go back to being automated. It's a pretty common utility so it should be in your distros package manager.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Wine: How do I input into a running Wine Program with Cyrillic Characters? Riddick Linux - Software 3 08-16-2009 11:58 AM
Send password input via bash script lowlifeish Linux - Software 4 02-22-2007 12:40 PM
Send input to child process cdog Linux - Software 5 02-07-2007 10:00 PM
input avoided in my c program. nflenz Programming 6 12-12-2006 01:47 PM
How do I send input to a web page? wswartz Linux - Software 2 07-16-2004 05:59 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:54 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration