Syntax error: Unterminated quoted string


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Syntax error: Unterminated quoted string
# 1  
Old 03-13-2009
Syntax error: Unterminated quoted string

I keep having problems when exicuting this file. It always gives me the error message "36: Syntax error: Unterminated quoted string"
If someone could help me edit this it would be much appreciated.

Code:
#!/bin/sh
#
# This will continue adding numbers
# untill the total is greater than 1,000
#
if test $num1=0
  then
    {
        echo "Please enter two numbers."
        read num1 Total
        echo "The number you entered is $num1"
        Total = `expr $Total + $num1`
    }
  elif test $num1>0
    then
      {
        echo "The current value is $Total."
        echo "Please enter another number."
        read num1
        echo "The number you entered is $num1"
        Total = `expr $Total + $num1`
      }
  elif test $num1<0
    then
      {
        echo "I'm sorry, the value you entered is invalid"
        echo "Please enter a number that is greater than zero."
        read num1
        echo "The number you entered is $num1"
        Total = `expr $Total + $num1`"
      }
  else
      {
        echo "Total is greater than 1,000\n"
        echo "CAN NOT COMPUTE!!!!!\n"
        echo "System shutdown"
      }
fi


Last edited by DukeNuke2; 03-13-2009 at 03:00 PM..
# 2  
Old 03-13-2009
Quote:
Originally Posted by evilSerph
Code:
#!/bin/sh

  elif test $num1<0
    then
      {
        echo "I'm sorry, the value you entered is invalid"
        echo "Please enter a number that is greater than zero."
        read num1
        echo "The number you entered is $num1"
        Total = `expr $Total + $num1`" 
      }
  
fi

delete the red "
# 3  
Old 03-13-2009
I looked over that section so many times and can't believe I missed that.
Thanks
# 4  
Old 03-13-2009
another thing, I can't seem to get the following to appear
Total = `expr $Total + $num1`

besides that i need it to loop intil the final value reaches higher than 1000

If anyone could help, again it would be much appreciated.
# 5  
Old 03-13-2009
delete the spaces...

Code:
Total=$(expr ...+...)

# 6  
Old 03-13-2009
Thanks again.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk string comparison unterminated quoted string andrule of thumb

I have the logic below to look up for matches within the columns between the two files with awk. In the if statement is where the string comparison is attempted with == The issue seems to be with the operands, as 1. when " '${SECTOR}' " -- double quote followed by single quote -- awk matches... (1 Reply)
Discussion started by: deadyetagain
1 Replies

2. Shell Programming and Scripting

Replace double quotes with a single quote within a double quoted string

Hi Froum. I have tried in vain to find a solution for this problem - I'm trying to replace any double quotes within a quoted string with a single quote, leaving everything else as is. I have the following data: Before: ... (32 Replies)
Discussion started by: pchang
32 Replies

3. UNIX for Dummies Questions & Answers

Getting " Unterminated quoted string"

Hi Guys, When I am executing the script #! /bin/bash SARBACKUPS=/home/pradeep/sarBackups cd /var/log/sysstat ls -1t sar* | while read SARNAME do cp -p "$SARNAME" $( echo "$SARBACKUPS"/"$HOSTNAME"_"$SARNAME"_"`date +"%Y%m%d`.bkup ) done I am getting final.sh: 1: Syntax... (3 Replies)
Discussion started by: Pradeep_1990
3 Replies

4. Shell Programming and Scripting

Deleting double quoted string from a line when line number is variable

I need to remove double quoted strings from specific lines in a file. The specific line numbers are a variable. For example, line 5 of the file contains A B C "string" I want to remove "string". The following sed command works: sed '5 s/\"*\"//' $file If there are multiple... (2 Replies)
Discussion started by: rennatsb
2 Replies

5. Shell Programming and Scripting

sed returns error "sed: -e expression #1, char 18: unterminated `s' command"

Hello All, I have something like below LDC100/rel/prod/libinactrl.a LAA2000/rel/prod/libinactrl.a I want to remove till first forward slash that is outputshould be as below rel/prod/libinactrl.a rel/prod/libinactrl.a How can I do that ??? (8 Replies)
Discussion started by: anand.shah
8 Replies

6. UNIX for Dummies Questions & Answers

sed error unterminated `s' command

I have list of data I have cut down to format: I am using sed command to remove the sed 's/ Returns error: sed: -e expression #1, char 5: unterminated `s' command Full code line is: cat textFile | cut -d ' ' -f 4 | cut ':' -f 1 | sed 's/ Thanks, Please use next time code tags... (2 Replies)
Discussion started by: maximus73
2 Replies

7. Shell Programming and Scripting

Take quoted output from one script as quoted input for another script

Hi, I have a script output.sh which produces the following output (as an example): "abc def" "ghi jkl" This output should be handled from script input.sh as input and the quotes should be treated as variable delimiters but not as regular characters. input.sh (processing positional... (2 Replies)
Discussion started by: stresing
2 Replies

8. Shell Programming and Scripting

Unterminated quoted string

Hello! I wroted a little script that should check for new updates on a server and get them if any. The problem is, every time I run it with sh, I'm getting an "script: 20: Syntax error: Unterminated quoted string" error! The problem is, there isn't any "unterminated quoted string" in my script:... (2 Replies)
Discussion started by: al0x
2 Replies

9. Shell Programming and Scripting

how to delete blanks inside a quoted string

Hi I need to update a string inside a file which looks like the following: PX_LIST=" 4119 2390 2294 2776 2897 4099 " Is there a way to get rid of the blanks after the first quote mark and before the last quote mark. This needs to be done ONLY for the string named PX_LIST (there are some... (4 Replies)
Discussion started by: aoussenko
4 Replies

10. UNIX for Dummies Questions & Answers

Unterminated string

While running a shell script i am getting this warning but the script is working fine.while running the blocks of the scripts individually its running fine.But while pasting it combinedly this is the warning..wat may be the reason behind this and how to resolve it (3 Replies)
Discussion started by: dr46014
3 Replies
Login or Register to Ask a Question