LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 10-22-2003, 01:33 PM   #1
thepryme
LQ Newbie
 
Registered: Oct 2003
Posts: 6

Rep: Reputation: 0
Two Linux shell scripting questions


I was wondering how you control read to stay on the previous line. Such as

What is your name: _______

instead of


What is your name:
________


And how would i move back to the appropriate sections with a script like this

read name:
echo "Your name is $name"
echo "Is this correct?"
read $correct

case in $correct

y)
echo "Welcome $name"
;;

n)
*** I want this to go back to the read name portion of the script***
;;

*)
*** I want this to go back to the read correct portion of the script ***
 
Old 10-22-2003, 02:08 PM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Quote:
I was wondering how you control read to stay on the previous line. Such as

What is your name: _______

instead of


What is your name:
________
Code:
#!/bin/sh

echo -n "What is your name: "
read NAME
echo "Hi, $NAME!"
Quote:
And how would i move back to the appropriate sections with a script like this

read name:
echo "Your name is $name"
echo "Is this correct?"
read $correct

case in $correct

[..snip..]
Code:
#!/bin/bash

STOP=0
while [ $STOP == 0 ] ; do
    echo -n "What is your name: "
    read NAME
    echo "Your name is $NAME"
    echo -n "Is this correct? "

    read CORRECT
    case  $CORRECT in
	"y" | "Y" | "yes" | "YES" | "Yes" ) 
	    echo "Welcome $NAME"
	    STOP=1
	    ;;

	"n" | "N" | "no" | "NO" | "No" ) 
	    echo "OK, I'll ask again..."
	    echo
	    ;;

	*) 
	    ;;
    esac
done
echo
You have quite a lot of errors in the code you posted.
Did you really try something yourself?
 
Old 10-22-2003, 02:10 PM   #3
thepryme
LQ Newbie
 
Registered: Oct 2003
Posts: 6

Original Poster
Rep: Reputation: 0
I have a working script that was something i just typed out quick to give you an idea or how im doing it
 
Old 10-22-2003, 02:12 PM   #4
thepryme
LQ Newbie
 
Registered: Oct 2003
Posts: 6

Original Poster
Rep: Reputation: 0
thanks for the help though
 
Old 10-22-2003, 04:24 PM   #5
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Quote:
I have a working script that was something i just typed out quick to give you an idea or how im doing it
Ok. Sorry I asked.
 
Old 10-23-2003, 07:01 AM   #6
wisey
LQ Newbie
 
Registered: Oct 2003
Location: Kent, England
Distribution: RH9 and Debian 3.0r1
Posts: 11

Rep: Reputation: 0
You could always use read's own parameters rather than writing
a heap of echo's

read -e -p "Enter you name please: " NAME
echo Your name is $NAME
 
  


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
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
shell interface vs shell scripting? I'm confused jcchenz Linux - Software 1 10-26-2005 03:32 PM
Linux Shell Scripting yaadhav Linux - Newbie 4 08-20-2005 03:05 PM
Linux Shell Scripting Help RowanB Programming 13 11-12-2004 04:07 PM
Linux Shell Scripting using BASH Help! fooforon Programming 5 02-05-2004 09:16 AM

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

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