LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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, 04: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, 04:53 PM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
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, 05: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, 06:01 PM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
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, 08: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



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

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

All times are GMT -5. The time now is 10:38 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