LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 09-24-2004, 05:27 PM   #1
Warmduvet
Member
 
Registered: Jun 2004
Location: New Zealand
Posts: 60

Rep: Reputation: 15
Bash question


Hi, I'm writing a script that requires the user to answer y/n

this line....
echo "Do you want to continue(y/n) \c"

should produce...
Do you want to continue(y/n) with the prompt directly after however I get this

Do you want to continue(y/n)\c

tried echo -n "Do you want to continue(y/n)" which produces

Do you want to continue(y/n)[xxx@xxx] $

which is where I want the prompt to be but without [xxx@xxx] $

TIA

WD
 
Old 09-24-2004, 05:53 PM   #2
crabboy
Moderator
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 120Reputation: 120
Code:
#!/bin/bash

echo -n "Do you want to continue (Y/N)? "
read A
Code:
 ./continue.sh 
Do you want to continue (Y/N)? Y
Works exactly as I'd expect.

What type of terminal are you using?

echo $TERM
 
Old 09-24-2004, 06:39 PM   #3
Warmduvet
Member
 
Registered: Jun 2004
Location: New Zealand
Posts: 60

Original Poster
Rep: Reputation: 15
Hi

What type of terminal are you using?

Linux and xterm

I set the value of PS1 in my .bash_profile so I dont have to use the bash "bash2.05..." prompt

would this be the cause?

rh9.0

WD
 
Old 09-24-2004, 07:01 PM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
Quote:
Originally posted by Warmduvet
I set the value of PS1 in my .bash_profile so I dont have to use the bash "bash2.05..." prompt

would this be the cause?
Could be. But to me it looks like didn't actually have a read command after echo command.

You need a read command after the echo to have your script waiting for input from the keyboard. If you don't, the script just ends, and the normal shell-prompt appears (after the echoed text, because you used the -n option).
 
Old 09-24-2004, 09:19 PM   #5
Warmduvet
Member
 
Registered: Jun 2004
Location: New Zealand
Posts: 60

Original Poster
Rep: Reputation: 15
Thats it!

newbie at this so thought I would see if the -n would give me what
the \c was supposed to before doing anything else. lol

thanks for the help

WD
 
  


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
A question about BASH operand Linux - Newbie 2 11-27-2005 10:49 PM
Bash Question mbjunior99 Programming 5 08-31-2005 05:33 AM
a bash question about while jiawj Linux - Newbie 3 07-14-2005 12:45 PM
bash question? shanenin Linux - Software 1 11-26-2004 01:22 PM
BASH question tpe Linux - Software 6 11-17-2004 09:59 PM


All times are GMT -5. The time now is 05:57 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration