The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
hardware assistance paulbryant SUN Solaris 4 05-27-2008 01:15 PM
Command assistance kmuir UNIX for Dummies Questions & Answers 0 02-26-2008 11:59 PM
I need an assistance mytilini boy Shell Programming and Scripting 1 05-25-2007 08:42 PM
KSH Script Assistance Brusimm Shell Programming and Scripting 3 05-10-2007 08:15 AM
Need Assistance yahoo14 UNIX for Dummies Questions & Answers 1 06-08-2006 10:21 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-05-2008
MaestroRage MaestroRage is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 20
While Loop assistance.

I am trying to make a simple while loop which reads in a text until the person types quit. And it's not working, and I know it's a rather simple problem I just can't seem to understand... Once again all assistance is greatly appreciated.

#!/bin/sh
astring="z"
while astring!="quit"
do
read astring
if astring="z"
then
astring="hello my name is Gsmith and I have 5 dollars"
echo $astring
else
echo "Never again"
fi
done
  #2 (permalink)  
Old 02-05-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Cool perhaps the issue was with variable names

try the following:

#!/bin/sh
astring="z"
while [ $astring != "quit" ]
do
read astring
if [ $astring = "z" ]
then
bstring="hello my name is Gsmith and I have 5 dollars"
echo $bstring
else
echo "Never again"
fi
done
  #3 (permalink)  
Old 02-05-2008
MaestroRage MaestroRage is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 20
Once again you've saved my day!

yes that was in fact the problem... odd how that worked. I will have to mind my variables much closer.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:56 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0