How to build a command in a script

Hi All

I am trying to build a script that will take data from a tab separated file and use that to split up a quicktime file. So far the code is as follows

#!/bin/sh
#test parsing of data

#fix excel file output returns
cat $1 | tr "\r" "\n" > $1.fix
printf "\n" >> $1.fix
mv $1.fix $1

FILE=$1

coffee_out=""
coffee_fill="splitAt"
coffee_end="selfcontained o output.mov $2"
textArray[0]="" # hold text
c=0 # counter
# read whole file in loop

while read c_out line
do
if test $c_out #check there is a value especial for /n for the fix from excel
then
textArray[$c]="$c_out $line" # store line
c=$(expr $c + 1) # increase counter by 1
coffee_out="$coffee_out $coffee_fill $c_out"
fi
done < $FILE

coffee_out="$coffee_out $coffee_end"

echo $coffee_out
splitmovie "$coffee_out"
#The final output should look something like
#splitmovie -splitAt 2 -splitAt 3 -self-contained -o output.mov recode.mov
exit 0

I call the script with two arguments the text file and the quicktime

./split.sh testdata.txt recode.mov

I am a newbie at writing scripts so it could be something really dumb.

I think it is most likely to be me using the wrong way to set the input for splitmovie.

Thanks for your help

Michael

Ok

i think i am hopefully focusing in on where the problem is.

when i print out $coffee_out at the end and look at it in a hex editor
the line looks like
splitmovie ...splitAt 3 ...self...contained ...o sdfsf.mov recode.mov.

Yet if i write it out by hand i get

splitmovie -splitAt 3 -self-contained -o sdfsf.mov recode.mov

It looks like i am not handling the - properly in the script

Any pointer would be gratefully appreciated

many thanks

michael

There's no need for cat:

tr "\r" "\n" < "$1" > "$1.fix"

Quote your variables, or the script will fail if any filenames contain spaces.

printf "\n" >> "$1.fix"
mv "$1.fix" "$1"
if test -n "$c_out"

There's no need for expr in the standard UNIX shell:

c=$(( $c + 1 ))

Apparently there are two different types of -

And the ones i where using where the wrong ones.

I am not sure how i got the wrong ones into my script but a few copy and pastes and now it is working.

Thank you for your help on how to improve my script so far.

many thanks

michael