LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Bash question (https://www.linuxquestions.org/questions/programming-9/bash-question-234867/)

Warmduvet 09-24-2004 04:27 PM

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

crabboy 09-24-2004 04:53 PM

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

Warmduvet 09-24-2004 05:39 PM

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

Hko 09-24-2004 06:01 PM

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).

Warmduvet 09-24-2004 08:19 PM

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


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