why is this code generating syntax error?pls help

#!/bin/sh

copy()
{
source=`stat -c %s $1`
dest=0
cd $2
while [ $source -ge $dest ];do
cp $1 $2 &
pct=`((100 * $dest) / $source )`
dest=`dest+1`
echo -en ".$pct%\b\b\b"
sleep 1
done
}

echo "starting now"
copy /file1 /tmp

This is the code i wrote to make cp address a progress bar...
But i have an error that goes like this....
"syntax error @ line 1: '/` unexpected"

May i know what syntax error it is?
I am actually trying to copy a file to /tmp ,through this routine, but why is this error??

Thanks

In POSIX shells:

pct=`((100 * $dest) / $source )`
# use this instead
pct= $(( (100 * $dest) / $source ))

Hi,

even the one you gave doenst seem to be working!!!!
I get an error like this,
"syntax error @ line 10 : '(' unexpected"
This is in reference to the pct=.....

Maybe you are looking for

((pct=100*dest/source))

... if your shell supports that syntax.

Unfortunately, the division is done using integer arithmetic, so you don't get a very precise result.

Further down, you also have a syntax error where you try to increment dest

((dest=dest+1))

You've copied the original rather imprecisely; you're not supposed to run the cp inside the while loop.

The loop appears to estimate that the copying rate will be one byte per second, which seems rather pessimistic.