FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 12-09-2009, 07:08 PM
Ray Parrish
 
Default Hidden syntax error somewhere

Hello,

I'm working on yet another script, and it's tossing an error that I
cannot locate the cause of. Here is the error message -

/home/ray/Bashscripts/TestScriptlet.sh: line 273: syntax error near
unexpected token `}'
/home/ray/Bashscripts/TestScriptlet.sh: line 273: `}'

The unexpected } is the one at the end of the function according to this
error message.

And here is the script portion causing it -

# This function detects web urls in a line of text.

function DetectHttp {
# Assign passed in values to a variable.
ThisLine="$1"
HttpStart=0
# Check for existence of http in ThisLine.
CharacterPosition=0
while [[ $CharacterPosition -lt ${#ThisLine} ]]; do
CharacterPosition=$(( $CharacterPosition + 1 ))
# Get next character of ThisLine
Character=${ThisLine:$CharacterPosition:1}
case $Character in
"h")
echo "HPos - $HPos"
HPos=$CharahterPosition
HChar="h";;
"t")
if [[ "$TChar" == "t" ]]
then
T2Pos=$CharacterPosition
echo "T2Pos - $T2Pos"
T2Char="t"
else
TPos=$CharacterPosition
echo "TPos - $TPos"
TChar="t"
fi;;
"p")
PPos=$CharacterPosition
echo "PPos - $PPos"
PChar="p";;
esac
if [[ "$HChar$TChar$T2Char$PChar" == "http" && $(( $PPos -
$HPos )) -eq 3 && $TPos -gt $HPos && $T2Pos -lt $PPos && $T2Pos -gt
$TPos ]]
then
HttpStart="$HPos"
echo "HttpStart - $HttpStart"
fi
done

if [[ $HttpStart -gt 0 ]]
CharacterPosition=0
SpaceNumber=0
then # Loop through string looking for spaces, and recording
their positions.
while [[ $CharacterPosition -lt ${#ThisLine} ]]; do
CharacterPosition=$(( $CharacterPosition + 1 ))
Character="${ThisLine:$CharacterPosition:1}"
case $Charachter in
" ")
SpacePositions[$SpaceNumber]=$CharacterPosition
SpaceNumber$(( $SpaceNumber + 1 ));;
esac
done
EndofURL=0
# Loop through SpacePositions looking for a space that is
past HPos.
for Positions in ${SpacePositions[@]}; do
if [[ $Positions -gt $HPos && $EndofURL -eq 0 ]]
then
EndofURL=$(( $Positions - 1 ))
echo "EndofURL - $EndofURL"
fi
done
if [[ $HttpStart -gt 0 ]]
then
LengthURL=$(( $EndofURL - $HttpStart ))
echo "Length = $Length"
URL=${ThisLine:$HttpStart:$LengthURL}
fi
echo "$URL"
}
# Main Program starts here.
Line="this is a test: http://www.rayslinks.com/index.html of if this works."
clear
DetectHttp "$Line"

I'm getting bleary eyed staring at this thing trying to figure ou what
I've done wrong, and I cannot find the mistake. I'm hoping some
additional eyes will spot what I'm doing wrong.

Thanks for any help you can be.

Later, Ray Parrish

--
The Future of Technology.
http://www.rayslinks.com/The%20Future%20of%20Technology.html
Ray's Links, a variety of links to usefull things, and articles by Ray.
http://www.rayslinks.com
Writings of "The" Schizophrenic, what it's like to be a schizo, and other
things, including my poetry.
http://www.writingsoftheschizophrenic.com



--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 

Thread Tools




All times are GMT. The time now is 10:59 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org