Review your favorite Linux distribution.
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 05-05-2011, 03:16 PM   #1
LQ Newbie
Registered: May 2011
Posts: 2

Rep: Reputation: 0
Question Bourne shell input from file using < then return control to user?

Hi all,

I have a program that I run from the terminal that requires manual input (it's matlab in mex debugging mode, matlab -Dgdb, which starts the GNU C debugger with its own custom settings).

Every time I run this program I always type in the same few commands in the program's interactive shell before I actually start working (for example: run -nojvm; stop at mexFunction; continue). I want to avoid typing these commands and I thought I could do this with shell scripting, saving the commands in the mycommands file, then running:

myprogram < mycommands

The problem is that this runs all the commands and then exits the program. I want it to run the commands and return control to me so I can run my commands. Is there a way to tell the shell to use a file or a string as the input to a program then immediately return control to the user without the exiting the program?
Old 05-05-2011, 04:44 PM   #2
Registered: Jan 2006
Location: Vancouver BC
Distribution: LFS, SLak, Gentoo, Debian
Posts: 291

Rep: Reputation: 36
not really
you might be able to change the program config to read the file on start and perform those steps
but the shell will only ever run the program until the end of the file then terminate it.
Old 05-06-2011, 02:04 AM   #3
LQ Guru
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,496

Rep: Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867
I am not sure of all its workings, but you might have a look at expect as a possible solution.
Old 05-07-2011, 12:15 AM   #4
LQ Newbie
Registered: May 2011
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks, I suspected it might be a bit involved.


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
Can expect return control of a spawned process to a shell script? duffrecords Programming 4 04-28-2010 02:33 PM
using an shell script how to change a value in a file according to the user input badrinath_tcs Linux - Software 6 09-28-2009 07:29 PM
bourne shell scripting ..input .. 91change Programming 2 07-29-2008 07:39 AM
getting function return values in a Bourne script? ocicat Programming 5 08-01-2007 07:01 AM
file permissions in bourne shell script bujecas Linux - General 2 07-12-2006 11:46 AM

All times are GMT -5. The time now is 05:42 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