Auto input with echo | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Auto input with echo

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-03-2013
lawsongeek lawsongeek is offline
Registered User
 
Join Date: Aug 2011
Last Activity: 3 January 2014, 1:13 PM EST
Posts: 60
Thanks: 0
Thanked 1 Time in 1 Post
Auto input with echo

in cygwin, cron-config will ask two inputs: yes or no.

1st question, answer is no
2nd question, answer is yes

my script:

echo no | cron-config

how do i pass yes to 2nd question ?
Sponsored Links
    #2  
Old 02-03-2013
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 16 April 2014, 7:57 AM EDT
Location: NM
Posts: 10,056
Thanks: 250
Thanked 756 Times in 711 Posts
Try a here document

Code:
cron-config <<EOF
no
yes
EOF

The bottom EOF pair ( could be any series of characters that are meaningless to the shell) has to be in column 1 -- leftmost column
Sponsored Links
    #3  
Old 02-03-2013
lawsongeek lawsongeek is offline
Registered User
 
Join Date: Aug 2011
Last Activity: 3 January 2014, 1:13 PM EST
Posts: 60
Thanks: 0
Thanked 1 Time in 1 Post
cool. thanks. worked perfectly!
    #4  
Old 02-03-2013
RudiC RudiC is online now Forum Advisor  
Registered User
 
Join Date: Jul 2012
Last Activity: 16 April 2014, 12:09 PM EDT
Location: Aachen, Germany
Posts: 3,510
Thanks: 50
Thanked 818 Times in 781 Posts
You could also try
Code:
$ { echo yes; echo no; } | cron-config

, or, depending on your system/shell,

Code:
$ echo -e "yes\nno" | cron-config

Sponsored Links
    #5  
Old 02-03-2013
Scrutinizer's Avatar
Scrutinizer Scrutinizer is online now Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 16 April 2014, 11:41 AM EDT
Location: Amsterdam
Posts: 8,872
Thanks: 230
Thanked 2,140 Times in 1,921 Posts

Code:
printf "%s\n" no yes | cron-config

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
accept input on an echo output robin_simple Shell Programming and Scripting 1 02-23-2012 07:42 PM
Putting echo output as input to stat Ebodee Shell Programming and Scripting 3 08-10-2010 10:41 PM
problem piping input to script with echo mcdef Shell Programming and Scripting 1 06-25-2009 12:53 PM
usage of echo with standard input calandrea Shell Programming and Scripting 13 10-27-2008 12:11 PM
suppress echo while reading input in expect sudhir_onweb Shell Programming and Scripting 1 07-23-2007 09:54 AM



All times are GMT -4. The time now is 12:10 PM.