Thank you InfoLinux (Nopriadi) for publish the code as below
Easy to Newbie for understanding
------------------------------------
watch_cdrom_read.sh
------------------------------------
#!/bin/sh
#nop, 2007, GPL
DEV=/dev/cdrom
LOGFILE=/tmp/`basename $0`.log
DD_BS=10M
alias ADIALOG="dialog --backtitle 'AutoRead (CDROM)'"
DIALOG_SIZE="10 40"
if [ $(id -u) -ne 0 ]
then
ADIALOG --msgbox 'Jalankanlah aplikasi ini sebagai root' $DIALOG_SIZE
exit 1
fi
while [ 1 ]
do
DESTDIR=/tmp/cdrom-data/`date +%d-%m-%Y--%H:%M:%S`
DESTDIR_CONTENT=$DESTDIR/content
DESTDIR_IMAGE=$DESTDIR/cdrom.iso
TEMP=/tmp/$0.`date +%s`.temp
mkdir -p $TEMP 1>/dev/null 2>&1
mount $DEV $TEMP 1>/dev/null 2>&1
if [ $? -ne 0 ]
then
ADIALOG --infobox 'IDLE: Masukkan CDROM Anda' $DIALOG_SIZE
else
ADIALOG --infobox 'CDROM terdeteksi' $DIALOG_SIZE
sleep 1
#copying data
ADIALOG --infobox 'Tunggulah sebentar...\nSedang membaca data' $DIALOG_SIZE
[ -d $DESTDIR_CONTENT ] && rm -rf $DESTDIR_CONTENT 1>/dev/null 2>&1
mkdir -p $DESTDIR 2>>$LOGFILE
cp -af $TEMP/ $DESTDIR_CONTENT 2>>$LOGFILE
umount $TEMP 2>> $LOGFILE
#end
#creating image
ADIALOG --infobox 'Tunggulah sebentar...\nSedang membuat image' $DIALOG_SIZE
dd if=$DEV of=$DESTDIR_IMAGE bs=$DD_BS seek=0 1>/dev/null 2>&1
[ $? -ne 0 ] && echo "dd-error" >> $LOGFILE
#end
TEST=`wc -c $LOGFILE | cut -d' ' -f1`
if [ $TEST -ne 0 ]
then
ADIALOG --msgbox 'Terjadi kesalahan dalam pembacaan.\nKeluarkanlah CDROM
Anda,\nKemudian tekan ENTER' $DIALOG_SIZE
else
ADIALOG --msgbox 'Selesai.\nKeluarkanlah CDROM Anda,\nKemudian tekan ENTER'
$DIALOG_SIZE
fi
rm -f $LOGFILE
fi
sleep 1
rmdir $TEMP
done
unalias ADIALOG
rmdir $TEMP
watch_cdrom_write.sh
#!/bin/sh
#nop, 2007, GPL
DEV=0,0,0
DEV_NODE=/dev/sr0
SPEED=24
LOGFILE=/tmp/`basename $0`.log
SRCDIR_IMAGE=/tmp/cdrom-src/cdrom.iso
alias ADIALOG="dialog --backtitle 'AutoWrite (CDROM)'"
DIALOG_SIZE="10 40"
if [ $(id -u) -ne 0 ]
then
ADIALOG --msgbox 'Jalankanlah aplikasi ini sebagai root' $DIALOG_SIZE
exit 1
fi
while [ 1 ]
do
cdrecord -dev=$DEV -atip 1>/dev/null 2>&1
if [ $? -ne 0 ]
then
ADIALOG --infobox 'IDLE: Masukkan CDROM Blank Anda' $DIALOG_SIZE
else
ADIALOG --infobox 'CDROM terdeteksi' $DIALOG_SIZE
sleep 1
#creating image
ADIALOG --infobox 'Tunggulah sebentar...\nSedang membakar CD' $DIALOG_SIZE
cdrecord gracetime=2 dev=$DEV speed=$SPEED $SRCDIR_IMAGE 1>/dev/null 2>&1
[ $? -ne 0 ] && echo "cdrecord-error" >> $LOGFILE
#end
eject $DEV_NODE
TEST=`wc -c $LOGFILE | cut -d' ' -f1`
if [ $TEST -ne 0 ]
then
ADIALOG --msgbox 'Terjadi kesalahan dalam proses burn.\nTutup tray CDROM dan tekan
ENTER.' $DIALOG_SIZE
else
ADIALOG --msgbox 'Selesai.\nTutup tray CDROM dan tekan ENTER.' $DIALOG_SIZE
fi
rm -f $LOGFILE
fi
sleep 3
done
unalias ADIALOG
rmdir $TEMP
watch_floppy_disk_read.sh
#!/bin/sh
#nop, 2007, GPL
DEV=/dev/fd0
LOGFILE=/tmp/`basename $0`.log
DD_BS=100k
alias ADIALOG="dialog --backtitle 'AutoRead (FLOPPY DISK)'"
DIALOG_SIZE="10 40"
if [ $(id -u) -ne 0 ]
then
ADIALOG --msgbox 'Jalankanlah aplikasi ini sebagai root' $DIALOG_SIZE
exit 1
fi
while [ 1 ]
do
DESTDIR=/tmp/floppy-data/`date +%d-%m-%Y--%H:%M:%S`
DESTDIR_CONTENT=$DESTDIR/content
DESTDIR_IMAGE=$DESTDIR/floppy.img
TEMP=/tmp/$0.`date +%s`.temp
mkdir -p $TEMP 1>/dev/null 2>&1
mount $DEV $TEMP 1>/dev/null 2>&1
if [ $? -ne 0 ]
then
ADIALOG --infobox 'IDLE: Masukkan Floppy Disk Anda' $DIALOG_SIZE
else
ADIALOG --infobox 'Floppy Disk terdeteksi' $DIALOG_SIZE
sleep 1
#copying data
ADIALOG --infobox 'Tunggulah sebentar...\nSedang membaca data' $DIALOG_SIZE
[ -d $DESTDIR_CONTENT ] && rm -rf $DESTDIR_CONTENT 1>/dev/null 2>&1
mkdir -p $DESTDIR 2>>$LOGFILE
cp -af $TEMP/ $DESTDIR_CONTENT 2>>$LOGFILE
umount $TEMP 2>> $LOGFILE
#end
#creating image
ADIALOG --infobox 'Tunggulah sebentar...\nSedang membuat image' $DIALOG_SIZE
dd if=$DEV of=$DESTDIR_IMAGE bs=$DD_BS seek=0 1>/dev/null 2>&1
[ $? -ne 0 ] && echo "dd-error" >> $LOGFILE
#end
TEST=`wc -c $LOGFILE | cut -d' ' -f1`
if [ $TEST -ne 0 ]
then
ADIALOG --msgbox 'Terjadi kesalahan dalam pembacaan.\nKeluarkanlah Floppy Disk
Anda,\nKemudian tekan ENTER' $DIALOG_SIZE
else
ADIALOG --msgbox 'Selesai.\nKeluarkanlah Floppy Disk Anda,\nKemudian tekan ENTER'
$DIALOG_SIZE
fi
rm -f $LOGFILE
fi
sleep 1
rmdir $TEMP
done
unalias ADIALOG
rmdir $TEMP
watch_floppy_disk_write.sh
#!/bin/sh
#nop, 2007, GPL
DEV=/dev/fd0
LOGFILE=/tmp/`basename $0`.log
SRCDIR_CONTENT=/tmp/floppy-src/content
alias ADIALOG="dialog --backtitle 'AutoWrite (FLOPPY DISK - CONTENT)'"
DIALOG_SIZE="10 40"
if [ $(id -u) -ne 0 ]
then
ADIALOG --msgbox 'Jalankanlah aplikasi ini sebagai root' $DIALOG_SIZE
exit 1
fi
while [ 1 ]
do
TEMP=/tmp/$0.`date +%s`.temp
mkdir -p $TEMP 1>/dev/null 2>&1
mount $DEV $TEMP 1>/dev/null 2>&1
if [ $? -ne 0 ]
then
ADIALOG --infobox 'IDLE: Masukkan Floppy Disk Anda' $DIALOG_SIZE
else
ADIALOG --infobox 'Floppy Disk terdeteksi' $DIALOG_SIZE
sleep 1
#copying data to floppy
ADIALOG --infobox 'Tunggulah sebentar...\nSedang mengopi data ke floppy' $DIALOG_SIZE
cp -af $SRCDIR_CONTENT $TEMP 2>>$LOGFILE
umount $TEMP 2>> $LOGFILE
#end
TEST=`wc -c $LOGFILE | cut -d' ' -f1`
if [ $TEST -ne 0 ]
then
ADIALOG --msgbox 'Terjadi kesalahan dalam penulisan.\nKeluarkanlah Floppy Disk Anda,\
nKemudian tekan ENTER' $DIALOG_SIZE
else
ADIALOG --msgbox 'Selesai.\nKeluarkanlah Floppy Disk Anda,\nKemudian tekan ENTER'
$DIALOG_SIZE
fi
rm -f $LOGFILE
fi
sleep 1
rmdir $TEMP
done
unalias ADIALOG
rmdir $TEMP
watch_floppy_disk_write_img.sh
#!/bin/sh
#nop, 2007, GPL
DEV=/dev/fd0
LOGFILE=/tmp/`basename $0`.log
SRCDIR_IMAGE=/tmp/floppy-src/floppy.img
DD_BS=100k
alias ADIALOG="dialog --backtitle 'AutoWrite (FLOPPY DISK - IMAGE)'"
DIALOG_SIZE="10 40"
if [ $(id -u) -ne 0 ]
then
ADIALOG --msgbox 'Jalankanlah aplikasi ini sebagai root' $DIALOG_SIZE
exit 1
fi
while [ 1 ]
do
TEMP=/tmp/$0.`date +%s`.temp
mkdir -p $TEMP 1>/dev/null 2>&1
mount $DEV $TEMP 1>/dev/null 2>&1
if [ $? -ne 0 ]
then
ADIALOG --infobox 'IDLE: Masukkan Floppy Disk Anda' $DIALOG_SIZE
else
ADIALOG --infobox 'Floppy Disk terdeteksi' $DIALOG_SIZE
sleep 1
umount $DEV
#creating image
ADIALOG --infobox 'Tunggulah sebentar...\nSedang menulis image ke floppy' $DIALOG_SIZE
dd if=$SRCDIR_IMAGE of=$DEV bs=$DD_BS seek=0 1>/dev/null 2>&1
[ $? -ne 0 ] && echo "dd-error" >> $LOGFILE
end
TEST=`wc -c $LOGFILE | cut -d' ' -f1`
if [ $TEST -ne 0 ]
then
ADIALOG --msgbox 'Terjadi kesalahan dalam penulisan.\nKeluarkanlah Floppy Disk Anda,\
nKemudian tekan ENTER' $DIALOG_SIZE
else
ADIALOG --msgbox 'Selesai.\nKeluarkanlah Floppy Disk Anda,\nKemudian tekan ENTER'
$DIALOG_SIZE
fi
rm -f $LOGFILE
fi
sleep 1
rmdir $TEMP
done
unalias ADIALOG
rmdir $TEMP
watch_usb_flash_disk_read.sh
#!/bin/sh
#nop, 2007, GPL
DEV=/dev/sda1
LOGFILE=/tmp/`basename $0`.log
alias ADIALOG="dialog --backtitle 'AutoRead (USB FLASH DISK)'"
DIALOG_SIZE="10 40"
if [ $(id -u) -ne 0 ]
then
ADIALOG --msgbox 'Jalankanlah aplikasi ini sebagai root' $DIALOG_SIZE
exit 1
fi
while [ 1 ]
do
DESTDIR=/tmp/usbflashdisk-data/`date +%d-%m-%Y--%H:%M:%S`
DESTDIR_CONTENT=$DESTDIR/content
if [ ! -e $DEV ]
then
ADIALOG --infobox 'IDLE: Masukkan USB Flash Disk Anda' $DIALOG_SIZE
else
ADIALOG --infobox 'USB Flash Disk terdeteksi' $DIALOG_SIZE
sleep 1
TEMP=/tmp/$0.`date +%s`.temp
mkdir -p $TEMP 1>/dev/null 2>&1
mount $DEV $TEMP 1>/dev/null 2>&1
#copying data
ADIALOG --infobox 'Tunggulah sebentar...\nSedang membaca data' $DIALOG_SIZE
[ -d $DESTDIR_CONTENT ] && rm -rf $DESTDIR_CONTENT 1>/dev/null 2>&1
mkdir -p $DESTDIR 2>>$LOGFILE
cp -af $TEMP/ $DESTDIR_CONTENT 2>>$LOGFILE
umount $TEMP 2>> $LOGFILE
#end
TEST=`wc -c $LOGFILE | cut -d' ' -f1`
if [ $TEST -ne 0 ]
then
ADIALOG --msgbox 'Terjadi kesalahan dalam pembacaan.\nKeluarkanlah USB Flash Disk
Anda,\nKemudian tekan ENTER' $DIALOG_SIZE
else
ADIALOG --msgbox 'Selesai.\nKeluarkanlah USB Flash Disk Anda,\nKemudian tekan
ENTER' $DIALOG_SIZE
fi
rm -f $LOGFILE
rmdir $TEMP
fi
sleep 1
done
unalias ADIALOG
rmdir $TEMP
watch_usb_flash_disk_write.sh
#!/bin/sh
#nop, 2007, GPL
DEV=/dev/sda1
LOGFILE=/tmp/`basename $0`.log
SRCDIR_CONTENT=/tmp/usbflashdisk-src/content
alias ADIALOG="dialog --backtitle 'AutoWrite (USB FLASH DISK)'"
DIALOG_SIZE="10 40"
if [ $(id -u) -ne 0 ]
then
ADIALOG --msgbox 'Jalankanlah aplikasi ini sebagai root' $DIALOG_SIZE
exit 1
fi
while [ 1 ]
do
if [ ! -e $DEV ]
then
ADIALOG --infobox 'IDLE: Masukkan USB Flash Disk Anda' $DIALOG_SIZE
else
ADIALOG --infobox 'USB Flash Disk terdeteksi' $DIALOG_SIZE
sleep 2
TEMP=/tmp/$0.`date +%s`.temp
mkdir -p $TEMP 1>/dev/null 2>&1
mount $DEV $TEMP 1>/dev/null 2>&1
#copying data to USB Flash Disk
ADIALOG --infobox 'Tunggulah sebentar...\nSedang mengopi data ke USB Flash Disk'
$DIALOG_SIZE
cp -af $SRCDIR_CONTENT $TEMP 2>>$LOGFILE
umount $TEMP 2>> $LOGFILE
#end
TEST=`wc -c $LOGFILE | cut -d' ' -f1`
if [ $TEST -ne 0 ]
then
ADIALOG --msgbox 'Terjadi kesalahan dalam penulisan.\nKeluarkanlah USB Flash Disk
Anda,\nKemudian tekan ENTER' $DIALOG_SIZE
else
ADIALOG --msgbox 'Selesai.\nKeluarkanlah USB Flash Disk Anda,\nKemudian tekan
ENTER' $DIALOG_SIZE
fi
rm -f $LOGFILE
rmdir $TEMP
fi
sleep 1
done
unalias ADIALOG
rmdir $TEMP
=================
Reference : INFOLINUX
- Home
- Activities
- Dimensional Control
- Total Angola - KAOMBO
- ENI - Jangkrik
- Iraq Platform
- AL Wasit --HASBAH - ARABIYAH
- Chevron - Gorgon
- Ichthys LNG Project | INPEX
- BP Tangguh
- Saipem Nigeria - Project EGINA
- Saipem Misr Eqypt - Project Zohr
- PHE ONWJ -3D Laser Scanning Surveyor
- FORMOSA 2 - Wind Farm Offshore
- NNG - Wind Offhore
- BP Senegal Tortue
- Software Surveyor
- Hardware Surveyor
- Contact
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment