Results 1 to 4 of 4
Hi all,
I searched to find out a few cp scripts that had progress bar, but did not compromise on performance, when my efforts were in vain i went ahead ...
- 05-24-2008 #1Just Joined!
- Join Date
- May 2008
- Posts
- 20
help needed in debugging a cp script!!urgent,pls
Hi all,
I searched to find out a few cp scripts that had progress bar, but did not compromise on performance, when my efforts were in vain i went ahead and wrote one of my own ,taking i/p frm other scripts...
But this is causing some errors and am unable to debug it.....pls help
Here is the code
#!/bin/bash
source=`stat -c %s $1`
dest=`stat -c %s $2`
while [ $source -ge $dest ];do
cp -f $1 $2 &
pct=$((( $dest * 100) / $source ))
dest=`expr $dest+1`
echo "$pct%"
done
bash3.2#./copy.sh <file1> <file2>
Error:
line 6:[0+1 interger expression expected ] ??
(Then i get the prompt), bash 3.2#No space left on the device
What does this mean???
- 05-25-2008 #2
can you please run your script as follows and post the output. so we will be able to track the error down.
here you are trying to compare with the wrong operator. when we get the above output it will be clear.Code:bash -x ./your_script_name
Linux and me it's a love story
- 05-27-2008 #3Just Joined!
- Join Date
- May 2008
- Posts
- 20
This is what it says when i run with the -x opt...Code:+ echo 'now starting' now starting + copy /solaris.zlib /tmp/solaris.zlib + '[' 2 = 2 ']' ++ /usr/bin/stat -c %s /solaris.zlib + source=561624064 + dest=0 + '[' 561624064 -gt 0 ']' + /usr/bin/cp -f /solaris.zlib /tmp/solaris.zlib ++ /usr/bin/stat -c %s /tmp/solaris.zlib + dest=0 ++ /usr/bin/expr '0*100' + pct='0*100' ++ /usr/bin/expr '0*100/561624064' ++ /usr/bin/bc + pct1=0 + echo '0%\c\r' 0%\c\r ++ expr 0+1 + dest=0+1 + sleep 1 + '[' 561624064 -gt 0+1 ']' cpy.sh: line 9: [: 0+1: integer expression expected
The error is with the while loop declaration...but i am not sure why?
Could you pls help?
However the cp is happenning correctly ..
I checked it out by copying a audio file from one loc to another,and played the file in the destination...it was working properly
Thanks
- 05-27-2008 #4
hi,
the problem is here in the following instruction
you did not put spaces around the + sign. so when you execute this bash will replace $dest by its value (0 in this case) and dest will be the string 0+1.Code:dest=`expr $dest+1`
so in the following comparison you get a compatibility error.Linux and me it's a love story


Reply With Quote