Read from script

Hi all.

I'm a newbie of bash scripting.

I need to create a script to have a rotate backup with 5 USB DISK on a work week.
With e2label, I've labelled all disk with all day of the week ( e.g. Monday, Tuesday, Thursday,... ).

How can I read if I've plugged the right device ?!?!

I find the right day with "date +%A".

Thanks a lot.

filloweb.

This is my script:

#!/bin/sh
#Device check

RIGHT_BACKUP_SUPPORT=`date +%A`
USB_DISK_DEVICE=`/sbin/blkid | grep "${RIGHT_BACKUP_SUPPORT}" |cut -d: -f1`
USB_DISK_LABEL=`/sbin/e2label "${USB_DISK_DEVICE}"`

if
    [ "${USB_DISK_LABEL}" = "${RIGHT_BACKUP_SUPPORT}" ];
then
    echo "The right disk is in !!!!";
else
    echo "Change it!!!"
fi

When the wrong disk is attached, I've some error:

[root@linviterie Desktop]# ./device_check.sh 
/sbin/e2label: No such file or directory while trying to open 
Couldn't find valid filesystem superblock.
Change it!!!
[root@linviterie Desktop]# 

I need to implement a mail whit a request to change the wrong ( with label in mail ) to the right disk.

Thanks.
filloweb.

USB_DISK_LABEL=`/sbin/e2label "${USB_DISK_DEVICE}" 2>/tmp/disk.txt`
if [ $? -ne 0 ]; then
mailx -s "Replace disk" abc@dot.com < /tmp/disk.txt
exit 1
fi

cheers,
Devaraj Takhellambam

Hi,

I can't understand...

Is right this?!?!

#!/bin/sh
#Device check
RIGHT_BACKUP_SUPPORT=`date +%A`
USB_DISK_DEVICE=`/sbin/blkid | grep "${RIGHT_BACKUP_SUPPORT}" |cut -d: -f1`
USB_DISK_LABEL=`/sbin/e2label "${USB_DISK_DEVICE}" 2>/tmp/disk.txt`
if [ $? -ne 0 ]; then
mailx -s "Replace disk" f.a@b.c < /tmp/disk.txt
exit 1
fi

Thanks.