Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

What is wrong with this script?

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 05-12-2011   -   Original Discussion by Oman_Member
Oman_Member's Unix or Linux Image
Oman_Member Oman_Member is offline
Banned
 
Join Date: May 2011
Last Activity: 19 May 2011, 10:24 AM EDT
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
What is wrong with this script?

I write this script and do not no whrer the wrong!!
Can anyone hlep me?

#=========================================
Script Name: shell_script1
#=========================================


Code:
looptrack=y
while [ “$looptrack” = 1 ]
do
echo -n “Type in the account number:” read account
echo -n “Type the first and last name:” ; read full_name
echo -n “Type the age:” red age
echo -n “Enter another record?” ; read looptrack
finish

Sponsored Links
    #2  
Old Unix and Linux 05-12-2011   -   Original Discussion by Oman_Member
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 21 May 2018, 8:18 AM EDT
Location: Amsterdam
Posts: 11,805
Thanks: 543
Thanked 3,440 Times in 3,033 Posts
- looptrack is initialised to y instead of 1
- Use done instead of finish.
- Use regular " instead of and
-
Use read instead of red
- Separate commands by newline or semicolon

Last edited by Scrutinizer; 05-12-2011 at 05:18 AM..
Sponsored Links
    #3  
Old Unix and Linux 05-12-2011   -   Original Discussion by Oman_Member
frans's Unix or Linux Image
frans frans is offline Forum Advisor  
Registered User
 
Join Date: Oct 2009
Last Activity: 1 February 2016, 9:47 AM EST
Location: France
Posts: 839
Thanks: 4
Thanked 54 Times in 53 Posts


Code:
while condition; do
    ...
done

and your double quotes look strange...

if looptrack = 'y' then looptrack != '1' !!! because 'y' != '1'
    #4  
Old Unix and Linux 05-12-2011   -   Original Discussion by Oman_Member
methyl's Unix or Linux Image
methyl methyl is offline
Registered User
 
Join Date: Mar 2008
Last Activity: 8 June 2016, 9:58 PM EDT
Posts: 6,402
Thanks: 288
Thanked 676 Times in 645 Posts
The slandy quotes “ ” look like they have come from Microsoft Word and are not valid in a unix script. They should be standard double quotes " " . You need to be using a unix editor to create a unix script file in the correct character set.

After taking into account the advice from various posters, please post the new version and show what happens when you execute the script. It is hard to suggest changes without knowing what the script is designed to do.
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
ps script - What is wrong with it please? linuxrose Shell Programming and Scripting 1 04-03-2011 10:12 AM
What's wrong with my script .... heyitsmeok Shell Programming and Scripting 7 05-21-2010 10:32 AM
Script Gone Wrong ibzee33 Shell Programming and Scripting 14 05-16-2010 03:44 AM
something wrong with this script?? fusion76 Shell Programming and Scripting 2 02-01-2005 12:24 AM
What is wrong with my script? Lem2003 UNIX for Dummies Questions & Answers 6 05-29-2003 01:17 AM



All times are GMT -4. The time now is 12:48 PM.