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: 7 November 2014, 9:58 PM EST
Posts: 77
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: 21 November 2014, 12:22 PM EST
Location: NM
Posts: 10,278
Thanks: 287
Thanked 814 Times in 756 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: 7 November 2014, 9:58 PM EST
Posts: 77
Thanks: 0
Thanked 1 Time in 1 Post
cool. thanks. worked perfectly!
    #4  
Old 02-03-2013
RudiC RudiC is offline Forum Advisor  
Registered User
 
Join Date: Jul 2012
Last Activity: 21 November 2014, 1:05 PM EST
Location: Aachen, Germany
Posts: 4,671
Thanks: 78
Thanked 1,153 Times in 1,083 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 offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 21 November 2014, 1:23 PM EST
Location: Amsterdam
Posts: 9,602
Thanks: 292
Thanked 2,444 Times in 2,192 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 08:42 PM
Putting echo output as input to stat Ebodee Shell Programming and Scripting 3 08-10-2010 11:41 PM
problem piping input to script with echo mcdef Shell Programming and Scripting 1 06-25-2009 01:53 PM
usage of echo with standard input calandrea Shell Programming and Scripting 13 10-27-2008 01:11 PM
suppress echo while reading input in expect sudhir_onweb Shell Programming and Scripting 1 07-23-2007 10:54 AM



All times are GMT -4. The time now is 02:57 PM.