LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-13-2008, 11:41 PM   #1
say_hi_ravi
Member
 
Registered: Jan 2008
Posts: 75

Rep: Reputation: 15
Pass "yes" or "no" to the shell script


Hi Guys,

I am writing one shell script which runs one command. Whenever this script is executed at the point of command execution it asks for "yes" or "no" type questions. I want to pass "yes" parameter to these questions. How can I automatically pass "yes" or "no" to these questions. I want the script to be executed without prompting for "yes" or "no".

Thanks,
Ravi
 
Old 02-13-2008, 11:46 PM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
This answers "n"
Code:
script_or_command < <(yes n)
This answers "y"
Code:
script_or_command < <(yes y)
I'll often use this with "mv -i" to prevent overwriting files that already exist.
 
Old 02-13-2008, 11:50 PM   #3
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Code:
( echo yes && \
  echo no ) \
 | ./yourscript
ta0kira
 
Old 02-13-2008, 11:58 PM   #4
say_hi_ravi
Member
 
Registered: Jan 2008
Posts: 75

Original Poster
Rep: Reputation: 15
Thank you guys for your prompt replies.

-Ravi
 
  


Reply


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
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 01:03 AM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
Shell Script: Find "Word" Run "Command" granatica Linux - Software 5 07-25-2007 07:42 AM
LXer: Displaying "MyComputer", "Trash", "Network Servers" Icons On A GNOME Desktop LXer Syndicated Linux News 0 04-02-2007 08:31 AM
Can't install "glibmm" library. "configure" script can't find "sigc++-2.0&q kornerr Linux - General 4 05-10-2005 02:32 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:35 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration