Visit Jeremy's Blog.
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 11-22-2010, 12:08 PM   #1
LQ Newbie
Registered: May 2010
Posts: 6

Rep: Reputation: 0
Crontab Script Confirmation

Hey all,

I have a quick question involving crontab and a script I want to run with it. The script generates and sends an email to group members who are on-call for a given day, but when you run it this appears

'Run This Script?'

The script will run when you enter 'y' or 'yes' and then press enter.

I'm trying to give that input via another script which runs the first one and then waits for the prompt to input a 'y'

How can I make a script which waits for a prompt and then gives it input? I'm stuck on this... and if there is a better way to do it please let me know.
Old 11-22-2010, 12:24 PM   #2
Registered: Oct 2010
Location: New England, USA
Distribution: OpenSUSE/Slackware64/RHEL/Mythbuntu
Posts: 187

Rep: Reputation: 39
Bash script? Perl script?

use the "expect" function in bash to wait for a reply.

man expect
Old 11-22-2010, 12:31 PM   #3
LQ Newbie
Registered: May 2010
Posts: 6

Original Poster
Rep: Reputation: 0
That looks like exactly what I want.

To give you more information, the script that makes/sends the emails is in perl (which I don't know very well, and wasn't written by me), and the script calling the perl is in bash.

So if I use expect in the bash script after calling the perl script I should be able to get it to give the perl script the ok to continue?

I do have one last question.
If I am replacing my shell script with an expect script that I want to run the perl and then give the perl input it'd look something like this right?

spawn perl
expect "Run This Script?"
send "y"

Sorry for all the questions, expect is a new tool to me.

Last edited by stodds; 11-22-2010 at 12:44 PM.
Old 11-22-2010, 01:01 PM   #4
LQ Guru
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Another option: if the answer is always "yes" you can try the yes command as in:
yes | perl /path/to/
actually you can output any string with the yes command, but without any argument the default answer is 'y'. Hope this helps.
Old 11-22-2010, 01:09 PM   #5
LQ Newbie
Registered: May 2010
Posts: 6

Original Poster
Rep: Reputation: 0
hmm... I like that second idea much better, and it should work because the answer always is yes.


crontab, input, prompt

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
Runs Multiple shell script inside a main script using crontab srimal Linux - Newbie 4 10-22-2009 07:19 PM
Ask confirmation for every change performed by Sed script raimizou Programming 3 04-03-2009 06:03 AM
/etc/acpi/ and running a confirmation script. Romanus81 Slackware 10 01-21-2009 11:25 AM
shell script asking for confirmation? bikov_k Programming 6 11-04-2005 03:16 AM
Bash script - confirmation option satimis Programming 4 10-21-2004 08:29 AM > Forums > Linux Forums > Linux - Newbie

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