Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 11-12-2007, 07:42 AM   #1
LQ Newbie
Registered: Oct 2007
Location: São Paulo - Brazil
Distribution: Debian Etch 4.1 r1
Posts: 12

Rep: Reputation: 0
shell script in non interactive way


I have been googling for a while to solve a little problem in my script but I couldn't find any solution for it.

I have a shell script that requires an imput to be typed during its execution and I don't know how I can "answer" this prompt automatically, without having to interact with the script.

It's a script to restore an Oracle database. The script calls a .sql file, in this .sql file there is the following command:

recover database until cancel using backup controlfile;

after running this command the message below is displayed requiring an imput that can be: filename, AUTO or CANCEL.

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

I'm always going to use option "AUTO", so I need to find a way to tell the script to use this option whenever the prompt appears.

Any help will be very appreciated!

Best Regards,

Rodrigo Azevedo
Old 11-13-2007, 12:20 AM   #2
LQ Newbie
Registered: Apr 2005
Location: Lake Forest, CA
Distribution: RHEL
Posts: 7

Rep: Reputation: 0
Echo and a pipe

The first thing to try is just echoing the answer into the script:

# echo "AUTO" | ./

That is the simple answer. There are lots of others, but it really is a bit for trial and error to find the one that fits you own style.

Old 11-13-2007, 05:56 AM   #3
LQ Newbie
Registered: Oct 2006
Distribution: Ubuntu RHEL SLES Debian Backtrack
Posts: 12

Rep: Reputation: 0
There is a language made for this called "expect".

Try looking at that its very simple from what i hear and intergrates nicely with shell scripts.
Old 11-13-2007, 05:59 AM   #4
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 680Reputation: 680Reputation: 680Reputation: 680Reputation: 680Reputation: 680
If AUTO is the only response that you need, you can use the "yes" command:

./ < <(yes AUTO)
1 members found this post helpful.
Old 11-13-2007, 06:27 AM   #5
Senior Member
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,197

Rep: Reputation: 105Reputation: 105
Expect really is easy, and is the appropriate tool if you need interaction with a script or program. You can find it here:

There is also a very good O'Reilly book on Expect with TCL/TK.

Of course, if you only need a one liner input this one time, and the other suggestions work for you, then use those suggestions.
Old 11-13-2007, 06:39 AM   #6
LQ Newbie
Registered: May 2006
Posts: 18

Rep: Reputation: 0
after running this command the message below is displayed requiring an imput that can be: filename, AUTO or CANCEL
I am no oracle expert, but if your input is always going to be AUTO, then cant you hard code this into your script? If there is a facility to pass this argument to the command that you are issuing it would save you the hassle of the program prompting you for stdin.

ie recover database until cancel using backup controlfile --AUTO;

I made that last part up --AUTO ... it would be handy if you could do that i think.
Old 11-13-2007, 09:18 AM   #7
LQ Newbie
Registered: Oct 2007
Location: São Paulo - Brazil
Distribution: Debian Etch 4.1 r1
Posts: 12

Original Poster
Rep: Reputation: 0
Hello Everybody!!

I'm really thankful for your help and sorry for the delay. This issue was
solved by just putting the word "AUTO" after the recover command. I guess it
is an sql specific sintax because I have neven seen this kind of sintaxe
used in shell scripts.

The following is a piece of the code:

recover database until cancel using backup controlfile;
alter database open resetlogs;

Thank you guys again!!!

Obs: This language "express" seems to be very good... I'm going to spend
some time studying it.

Rodrigo Azevedo Medeiros


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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
script connecting to erlang shell works only in interactive mode ineya Linux - Server 1 10-25-2007 07:05 AM
how to know if the shell is interactive or not? anupamsr Linux - Newbie 2 01-20-2007 07:31 AM
shell script read non-interactive comtmr Linux - General 6 11-01-2006 06:54 AM
interactive and non-interactive shell linuxjamil Programming 3 09-03-2006 08:42 PM
Where is the shell interactive for ruby languaje? Manuel Tejada Red Hat 5 02-02-2004 08:30 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:23 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
Open Source Consulting | Domain Registration