LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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-03-2005, 09:07 PM   #1
Mr.McCormick
LQ Newbie
 
Registered: Aug 2004
Location: Redford, MI
Distribution: lfs 6.0-testing-20040913/ blfs 5.1 modifyed
Posts: 10

Rep: Reputation: 0
scripting question press any key to continue


hi i have a question about BASH scripting i what to put in a script a question (making it in a way interactive) that would say would you like to continue press y to continue or press n to cancel you know something along those lines


my knowledge for scripting in bash is very basic

Last edited by Mr.McCormick; 02-03-2005 at 09:22 PM.
 
Old 02-03-2005, 09:48 PM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Something like this....
Code:
echo
echo -n "                Do you want to proceed (Y/N)?"
read answer
if test "$answer" != "Y" -a "$answer" != "y";
then exit 0;
fi
 
Old 02-03-2005, 09:58 PM   #3
JoannesX
Member
 
Registered: Dec 2004
Location: Brazil
Distribution: Slackware
Posts: 99

Rep: Reputation: 15
Man... if you want a script even better than the one you're asking
copy EXACTLY, PERFECTLY the lines bellow to your script:
======================================================
#!/bin/bash
dialog --title "Question" --backtitle "Yes or no" \
--yesno "\nYes to continue and No to cancel" 15 50
value=$?
case $value in
0) "cal" ;;
1) echo "Cancelled" ;;
255) echo "You pressed ESC" ;;
esac
======================================================
read this:

1. the 3rd line (--yesno "\nYes to continue and No to cancel" 15 50) CAN NOT touch
the left of the screen. NO WAY.

2. don't forget to copy each semicolon, each little character...

3. if you choose "yes" you'll see the calendar of the month.

4. compare what happens if you choose "no" with what happens if you press ESC.

Wish you enjoy the result!
 
Old 02-04-2005, 03:47 AM   #4
Mr.McCormick
LQ Newbie
 
Registered: Aug 2004
Location: Redford, MI
Distribution: lfs 6.0-testing-20040913/ blfs 5.1 modifyed
Posts: 10

Original Poster
Rep: Reputation: 0
thank you very much they where both exactly what i wanted and i can addapt both to what i need it for
 
  


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
Key press Majestros Programming 2 02-14-2007 03:42 AM
boot failed: please change disks and press a key to continue bonovox86uk Red Hat 2 12-08-2004 04:16 PM
HEELLLP! Boot failed: please change disks and press any key to continue GeekFreak Red Hat 8 09-01-2004 03:51 AM
Boot failed: please change disk and press a key to continue zeewin Linux - Software 4 01-05-2004 10:39 PM
Boot failed: please change disks and press a key to continue. ChriSchmi Linux - Software 9 03-13-2002 01:34 PM

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

All times are GMT -5. The time now is 11:27 PM.

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