Unix/Linux 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 Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 02-03-2013
lawsongeek lawsongeek is offline
Registered User
 
Join Date: Aug 2011
Last Activity: 25 March 2015, 5:59 PM EDT
Posts: 81
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 Unix and Linux 02-03-2013
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 18 April 2015, 9:28 AM EDT
Location: NM
Posts: 10,428
Thanks: 328
Thanked 857 Times in 796 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 Unix and Linux 02-03-2013
lawsongeek lawsongeek is offline
Registered User
 
Join Date: Aug 2011
Last Activity: 25 March 2015, 5:59 PM EDT
Posts: 81
Thanks: 0
Thanked 1 Time in 1 Post
cool. thanks. worked perfectly!
    #4  
Old Unix and Linux 02-03-2013
RudiC RudiC is offline Forum Advisor  
Registered User
 
Join Date: Jul 2012
Last Activity: 18 April 2015, 6:23 AM EDT
Location: Aachen, Germany
Posts: 5,716
Thanks: 101
Thanked 1,504 Times in 1,413 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 Unix and Linux 02-03-2013
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 18 April 2015, 1:53 PM EDT
Location: Amsterdam
Posts: 10,103
Thanks: 326
Thanked 2,652 Times in 2,373 Posts

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

Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image 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 03:19 PM.