LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-25-2008, 12:59 PM   #1
jh111451
LQ Newbie
 
Registered: Jul 2008
Posts: 2

Rep: Reputation: 0
Read command in bash shell file doesn't work


I am trying to run a .sh script in bash. The script skips the first 'read' and stops at the second read in the script. Has anyone had this problem with Redhat/bash before? If so, did you find a fix.
Thanks,
jh111451
 
Old 07-25-2008, 01:18 PM   #2
heema
Senior Member
 
Registered: Sep 2003
Location: Egypt
Distribution: Arch
Posts: 1,528

Rep: Reputation: 47
can you post that script
 
Old 07-25-2008, 01:43 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by jh111451 View Post
I am trying to run a .sh script in bash. The script skips the first 'read' and stops at the second read in the script. Has anyone had this problem with Redhat/bash before? If so, did you find a fix.
Thanks,
jh111451
You don't necessarily have to post the whole script---but you have to give us some kind of information. For example, when you refer to the first and second read, is this in a loop?
 
Old 07-28-2008, 09:36 AM   #4
jh111451
LQ Newbie
 
Registered: Jul 2008
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by pixellany View Post
You don't necessarily have to post the whole script---but you have to give us some kind of information. For example, when you refer to the first and second read, is this in a loop?
The script is stopping at the first read but is storing the entered value in the variable associated with the second read (ln).
The script does not stop and prompt you to enter the last name or address.
I am running the script on as server. I am connected thru secure-shell.
Logged in as 'oracle' user.

Here is a test script I have been working with:
1 read -p "enter first name " -a fn;
2 echo "fn is " $fn;
3
4 printf "\n";
5 read -p "enter last name " -a ln;
6 printf "\n";
7 echo "ln is " $ln;
8
9 printf "\n";
10 read -p "enter address " -a ad;
11 printf "\n";
12 echo "ad is " $ad;
13
14 exit


Here is the result:
enter first name john

fn is

enter last name
ln is john

enter address
ad is
 
Old 07-28-2008, 08:35 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.x
Posts: 18,444

Rep: Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791
Well, that script works fine for me (assuming you don't actually have line nums )
 
  


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
bash shell script read file line by line. Darren[UoW] Programming 57 04-17-2016 06:07 PM
Bash Shell: Using the value of $A to read the value of $B ? TIGA Programming 7 04-25-2008 02:00 AM
about the bash shell command naihe2010 Programming 7 10-27-2005 12:40 AM
BASH Shell program Read a configuration File minil Programming 10 01-17-2005 04:37 AM
Trouble with bash read command Bebo Programming 5 05-21-2004 08:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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