LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

Reply
 
Search this Thread
Old 11-22-2010, 11:08 AM   #1
stodds
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, 11:24 AM   #2
udaman
Member
 
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.

Code:
man expect
 
Old 11-22-2010, 11:31 AM   #3
stodds
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?


#!/bin/expect
spawn perl NAMEOFPERLSCRIPT.pl
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 11:44 AM.
 
Old 11-22-2010, 12:01 PM   #4
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,503

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
Another option: if the answer is always "yes" you can try the yes command as in:
Code:
yes | perl /path/to/script.pl
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, 12:09 PM   #5
stodds
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.
 
  


Reply

Tags
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 06:19 PM
Ask confirmation for every change performed by Sed script raimizou Programming 3 04-03-2009 05:03 AM
/etc/acpi/acpi_handler.sh and running a confirmation script. Romanus81 Slackware 10 01-21-2009 10:25 AM
shell script asking for confirmation? bikov_k Programming 6 11-04-2005 02:16 AM
Bash script - confirmation option satimis Programming 4 10-21-2004 07:29 AM


All times are GMT -5. The time now is 09:38 PM.

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