| Author |
Message |
|
|
Post subject: rd-h2.sh malfunction?
Posted: Jun 06, 2008 - 12:07 PM
|
|

Joined: Dec 02, 2006
Posts: 154
Location: Copenhagen, Denmark
Status: Offline
|
|
when I try to run rd-h2.sh i get an error:
Code:
# ./rd-h2.sh
[: 201: ==: unexpected operator
./rd-h2.sh: 269: Syntax error: "do" unexpected (expecting "}")
It worked last time I used it (1 month ago?). Anyone else getting this? I got a fresh copy of the script from techpatterns, but the error message persists.... What could be wrong, -any ideas? |
_________________ linuxuser 377268
|
| |
|
|
|
 |
|
|
Post subject: rd-h2.sh malfunction?
Posted: Jun 06, 2008 - 12:24 PM
|
|

Joined: Nov 30, 2006
Posts: 1012
Location: Nimritz / Thüringen
Status: Offline
|
|
| Have u changed /bin/sh to dash? |
_________________
|
| |
|
|
|
 |
|
|
Post subject: RE: rd-h2.sh malfunction?
Posted: Jun 06, 2008 - 12:32 PM
|
|
Joined: Dec 03, 2006
Posts: 68
Location: Germany - Siegen
Status: Offline
|
|
| replace the first line #!/bin/sh with #!/bin/bash and it should work |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: rd-h2.sh malfunction?
Posted: Jun 06, 2008 - 12:32 PM
|
|
Joined: Dec 19, 2006
Posts: 1030
Status: Offline
|
|
There are a few bashisms in that script, it really needs to have its shebang line adjusted:
Code:
$ checkbashisms rd-h2.sh
possible bashism in rd-h2.sh line 176 (should be 'b = a'):
[ "$1" == 'err' ] && echo 'You entered an invalid option. Please use one of the following only:'
possible bashism in rd-h2.sh line 197 (should be 'b = a'):
if [ "$SPINNING_WHEEL" == 'true' ]
possible bashism in rd-h2.sh line 215 (local foo=bar):
local failed='' message1='' message2='' linebreak=''
possible bashism in rd-h2.sh line 234 (should be 'b = a'):
if [ "$failed" == 'true' ]
possible bashism in rd-h2.sh line 238 (echo -e):
echo -e $message2
possible bashism in rd-h2.sh line 247 (local foo=bar):
local ExDir=$( dirname $0 )
possible bashism in rd-h2.sh line 254 (local foo=bar):
local opt='' options='' doTheBackup='' removeBackup='' repeat=''
possible bashism in rd-h2.sh line 268 ('select' is not POSIX):
select opt in $options
possible bashism in rd-h2.sh line 287 (should be 'b = a'):
[ "$repeat" == 'true' ] && set_run_backup
possible bashism in rd-h2.sh line 288 (should be 'b = a'):
[ "$removeBackup" == 'true' ] && remove_backups
possible bashism in rd-h2.sh line 289 (should be 'b = a'):
[ "$doTheBackup" == 'true' ] && run_backups
possible bashism in rd-h2.sh line 298 (local foo=bar):
local month=$( date +%m )
possible bashism in rd-h2.sh line 333 (local foo=bar):
local response='' repeat='' deleteBackup=''
possible bashism in rd-h2.sh line 358 (should be 'b = a'):
[ "$repeat" == 'true' ] && remove_backups
possible bashism in rd-h2.sh line 359 (should be 'b = a'):
[ "$deleteBackup" == 'true' ] && delete_old_backup
possible bashism in rd-h2.sh line 364 (local foo=bar):
local removedDirectories=$( ls $BACKUP_LOCATION$BU_NU ) directory=''
possible bashism in rd-h2.sh line 376 (should be 'b = a'):
if [ "$SPINNING_WHEEL" == 'true' ]
possible bashism in rd-h2.sh line 401 (should be 'b = a'):
if [ "$SPINNING_WHEEL" == 'true' ]
possible bashism in rd-h2.sh line 417 (should be 'b = a'):
if [ "$SPINNING_WHEEL" == 'true' ]
possible bashism in rd-h2.sh line 433 (should be 'b = a'):
if [ "$SPINNING_WHEEL" == 'true' ]
possible bashism in rd-h2.sh line 452 (should be 'b = a'):
if [ "$SPINNING_WHEEL" == 'true' ]
possible bashism in rd-h2.sh line 477 ('function' is useless):
function spinning_wheel_activity_indicator()
possible bashism in rd-h2.sh line 479 (local foo=bar):
local completionText=''
possible bashism in rd-h2.sh line 480 (should be 'b = a'):
[ "$1" == 'delete' ] && completionText='backup directories removed'
possible bashism in rd-h2.sh line 481 (should be 'b = a'):
[ "$1" == 'backup' ] && completionText="$2 backed up"
possible bashism in rd-h2.sh line 489 (echo -e):
echo -ne "\b"
possible bashism in rd-h2.sh line 492 (echo -e):
echo -ne "\b"
possible bashism in rd-h2.sh line 495 (echo -e):
echo -ne "\b"
possible bashism in rd-h2.sh line 497 (unsafe echo with backslash):
echo -n "\\"
possible bashism in rd-h2.sh line 498 (echo -e):
echo -ne "\b"
possible bashism in rd-h2.sh line 500 (echo -e):
echo -ne "\b $completionText"
possible bashism in rd-h2.sh line 507 (local foo=bar):
local endTime=$( date +%s )
possible bashism in rd-h2.sh line 508 (local foo=bar):
local completedTime=$(( $endTime - $START_TIME ))
possible bashism in rd-h2.sh line 509 (local foo=bar):
local hours=$(( $completedTime / 3600 ))
possible bashism in rd-h2.sh line 510 (local foo=bar):
local remainingMinutes=$(( $completedTime % 3600 ))
possible bashism in rd-h2.sh line 511 (local foo=bar):
local minutes=$(( $remainingMinutes / 60 ))
possible bashism in rd-h2.sh line 512 (local foo=bar):
local seconds=$(( $remainingMinutes % 60 ))
possible bashism in rd-h2.sh line 513 (local foo=bar):
local hourText='' minuteText='' secondText='' plural=''
possible bashism in rd-h2.sh line 548 (should be 'b = a'):
[ "$DELETE_BACKUP" == 'true' ] && delete_old_backup
possible bashism in rd-h2.sh line 549 (should be 'b = a'):
[ "$DO_BACKUP" == 'true' -o "$DELETE_BACKUP" == 'true' ] && run_backups || set_run_backup
possible bashism in rd-h2.sh line 549 (should be 'b = a'):
[ "$DO_BACKUP" == 'true' -o "$DELETE_BACKUP" == 'true' ] && run_backups || set_run_backup
|
|
|
| |
|
|
|
 |
|
|
Post subject: RE: rd-h2.sh malfunction?
Posted: Jun 06, 2008 - 12:33 PM
|
|
Joined: Nov 25, 2006
Posts: 2571
Status: Offline
|
|
| While it's pretty obvious that the stricter dash complains about the bug in rd-h2.sh, it really needs to be fixed in the script itself - either by being lazy an using #!/bin/bash instead of the wrong #!/bin/sh for non-POSIX/ SUSv3 Skripts or by fixing the bug in rd-h2.sh. |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: rd-h2.sh malfunction?
Posted: Jun 06, 2008 - 05:24 PM
|
|
Joined: Nov 28, 2006
Posts: 4303
Status: Offline
|
|
that was an oversight, I'd changed all the #!/bin/sh to #!/bin/bash in all my other scripts and libraries etc, but I forgot to update that one, it's a fairly static script so I don't think about it much, but I'll upload a corrected version, and people using it should just update the first line to show: #!/bin/bash
clearly a lot of scripts out there are going to break though with changing to dash, since the convention was to use #!/bin/sh instead of the actual shell, which was now that I think of it a sort of typical sloppy shell scripting habit, most of which I'm starting to try to avoid now in all my new stuff, but I find these kinds of mistakes and oversights all the time in my stuff, because when I started I tended to follow examples I found on the web, which tend to be sloppy. Live and learn, precise is always better. |
_________________ sidux Maintenance script: dist-upgrade, kernel install, general utilities: smxi
Backup script [using rdiff-backup]: rd-h2.sh
|
| |
|
|
|
 |
|
|
Post subject: RE: rd-h2.sh malfunction?
Posted: Jun 06, 2008 - 05:31 PM
|
|
Joined: Nov 28, 2006
Posts: 4303
Status: Offline
|
|
<updated: uploaded fixed rd-h2.sh bu.tar.bz2 file, changed #!/bin/sh to #!/bin/bash
I'll also update the home page to let people know about that. |
_________________ sidux Maintenance script: dist-upgrade, kernel install, general utilities: smxi
Backup script [using rdiff-backup]: rd-h2.sh
|
| |
|
|
|
 |
|
|
Post subject:
Posted: Jun 06, 2008 - 11:09 PM
|
|

Joined: Dec 02, 2006
Posts: 154
Location: Copenhagen, Denmark
Status: Offline
|
|
yes i did change bin/sh to dash.
the resulting discussion is interesting, but im unable to deduct from the discussion if the script should actually work, or if it is now useless.
after changing #!/bin/sh to #!/bin/bash i get
Code:
# ./rd-h2.sh
Mounting your backup drive/partition now...
mount: no such partition found
==================================================================
The MOUNT_BU_DISK component failed to successfully complete its task. Error code was: 1
Please try to resolve the problem. The script is exiting now.
==================================================================
and i didnt fiddle with any settings regarding mounting unmounting (line 119+) this is whats in there:
Code:
#### BACKUP DISK / PARITION mount / umount ------------------
# << CHANGE TO FIT YOUR NEEDS >>
# if you are not going to be mounting/unmounting your backup partition / disk,
# then set value to blank:
# MOUNT_BU_DISK=""
# UNMOUNT_BU_DISK=""
# Note: you can use anything here, </dev/sdd1>; -L <disk label>; -U <disk uuid>
# replace <....> with your label,uuid, or /dev/...
# Syntax for label: mount -L <disklabel> $BACKUP_DIRECTORY
# Syntax for uuid: mount -U <uuid> $BACKUP_DIRECTORY
# Syntax for standard: mount </dev/sdd2> $BACKUP_DIRECTORY
# SAMPLE:
MOUNT_BU_DISK="mount -L backup-disk-1 $BACKUP_DIRECTORY"
UNMOUNT_BU_DISK="umount $BACKUP_DIRECTORY"
|
_________________ linuxuser 377268
|
| |
|
|
|
 |
|
|
Post subject:
Posted: Jun 08, 2008 - 06:35 PM
|
|
Joined: Nov 28, 2006
Posts: 4303
Status: Offline
|
|
This issue is as far as I know completely unrelated to the thread topic.
However, the error means what it says: the partition failed to mount.
Why? Probably because it's already mounted I'd guess.
This is easy to verify by simply, after you receive this error message, typing in the above commands manually, as root: mount -L backup-disk-1 /path/to/backup/directory
Obviously, you must have a backup disk with label backup-disk-1 installed or connected. |
_________________ sidux Maintenance script: dist-upgrade, kernel install, general utilities: smxi
Backup script [using rdiff-backup]: rd-h2.sh
|
| |
|
|
|
 |
|
|
Post subject:
Posted: Jun 09, 2008 - 06:37 PM
|
|

Joined: Dec 02, 2006
Posts: 154
Location: Copenhagen, Denmark
Status: Offline
|
|
thanks h2. I dont recall what stumbling steps I took to produce that error. The backup script runs smooth again now, - I just replaced it with my backup of it  |
_________________ linuxuser 377268
|
| |
|
|
|
 |
|
|