文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Solaris8系统中拷贝磁带内容的脚本程序

Solaris8系统中拷贝磁带内容的脚本程序

时间:2006-03-25  来源:ylzjl

首先把源磁盘里面的数据拷贝到文件系统,然后再拷贝到空白磁带中,可以重复拷贝多个拷贝磁带
#!/bin/sh
#
# Copyright@2005 HW Technologies Co., Ltd. All rights reserved.
#
# pragma ident   "@(#)tapecopy.sh    2006.03"
#
# This script can copy data from tape to another empty tape
#
# OS Version : Solaris 8 02/2004
#
# Hardware Supproted :Sun Blade 2500, Sun Fire V440, Sun Fire V890;
#
# User : root user
#
# Usage: #sh tapecopy.sh
#
# log file: /var/sadm/install/logs/copy_tape_to_tape_log.xxxxxxx
#
# author: ylzjl
#
################################################################################
/usr/bin/echo "********************************************************************************"
/usr/bin/echo "* Wellcom to use the tape copy program *"
/usr/bin/echo "* *"
/usr/bin/echo "* Author: ylzjl*"
/usr/bin/echo "* 2006.3 *"
/usr/bin/echo "********************************************************************************"
/usr/bin/echo "\n"
/usr/bin/echo "Below is available space information of the system "
/usr/bin/echo "-----------------------------------------------------------------------"
/usr/sbin/df -k | /usr/bin/grep -v cdrom | /usr/bin/egrep 'swap|dsk'
/usr/bin/echo "-----------------------------------------------------------------------"
/usr/bin/echo "\nPlease choose a file system to used for keeping the tape files,"
/usr/bin/echo "\nand guarantee the space of file system and can keep the tape files."
/usr/bin/echo "\nIf the space of file system can't keep the files in tapes, press 'q' stop operating."
/usr/bin/echo "'Ctrl +C' to quit from the program. "
/usr/bin/echo "\nPlease input the name of file system slected, or press 'q' to stop operating, "
/usr/bin/echo "\nor press 'Ctrl +C' to quit from the program.\c"
MONTH=`/usr/bin/date +%m`
DAY=`/usr/bin/date +%d`
HOUR=`/usr/bin/date +%H`
MIN=`/usr/bin/date +%M`
LOG=/var/sadm/install/logs/tape_copy_to_tape_log."$MONTH""$DAY""$HOUR""$MIN"

/usr/bin/cat /dev/null | tee $LOG

/usr/bin/echo "\nPlease input the path which you selected." | /usr/bin/tee -a $LOG
/usr/bin/echo "\nTemporary path:"
read _FS
if [ "$_FS" = "q" ]
then
    /usr/bin/echo "\nQuit from the program when users input 'q'." | /usr/bin/tee -a $LOG
    exit
fi

a="/"
if [ "$_FS" = "/" ]
then
    _PATH=/
else
    if [ ! -d "$_FS" ]
    then
        /usr/bin/echo "\nPlease create directory "\'$_FS\'" first." | /usr/bin/tee -a $LOG
        exit 1
    fi
    _PATH=$_FS$a
    if [ -f "$_PATH"*img ]
    then
        /usr/bin/rm "$_PATH"*img
    fi
fi

answer="n"
while [ "$answer" = "n" ]
do
    /usr/bin/echo "\nPlease insert your source tape." | /usr/bin/tee -a $LOG
    /usr/bin/echo "Are you ready [y/n]? \c"
    read answer
done

/usr/bin/mt rewind
_BLOCKS=1
while :
do
    /usr/bin/dd if=/dev/rmt/0n of="$_PATH""$_BLOCKS"".img" bs=126b | /usr/bin/tee -a $LOG

    if [ -s "$_PATH""$_BLOCKS"".img" ]
    then
        /usr/bin/echo "\nBlock $_BLOCKS had been copied to "$_PATH""$_BLOCKS"".img"" | /usr/bin/tee -a $LOG
        _BLOCKS=`expr $_BLOCKS + 1`
    else
        /usr/bin/echo "\nSource tape had been copied to file system." | /usr/bin/tee -a $LOG
        break
    fi
done

copytape()
{
    /usr/bin/mt rewind
    while [ $_BLOCKS -ne $count ]
    do
        /usr/bin/echo "\nIt is copying block $count..." | /usr/bin/tee -a $LOG
        /usr/bin/dd if="$_PATH""$count"".img" of=/dev/rmt/0n bs=126b
        count=`expr $count + 1`
    done
    /usr/bin/echo "\nSuccessful to copy tape, please label it and keep it properly." | /usr/bin/tee -a $LOG
    /usr/bin/echo "\nRewind and offline source tape..." | /usr/bin/tee -a $LOG
    /usr/bin/mt offline
}

/usr/bin/mt rewind
/usr/bin/mt offline
answer="y"
_TAPEACCOUNT=0
while [ "$answer" = "y" ]
do
    if [ $_TAPEACCOUNT -eq 0 ]
    then
        /usr/bin/echo "\nPlease insert an blank tape." | /usr/bin/tee -a $LOG
    else
        /usr/bin/echo "\nDo you want to copy another tape? Please insert another blank tape." | /usr/bin/tee -a $LOG
    fi

    /usr/bin/echo "Are you ready [y/n]? \c"
    read enter
    if [ "$enter" = "y" ]
    then
        count=1
        copytape
    else
        /usr/bin/echo "\nStop copying tape operation at present." | /usr/bin/tee -a $LOG
        break
    fi
    _TAPEACCOUNT=`expr $_TAPEACCOUNT + 1`
done

while [ $_BLOCKS -ne 0 ]
do
    /usr/bin/rm -f "$_PATH""$_BLOCKS"".img"
    _BLOCKS=`expr $_BLOCKS - 1`
done
/usr/bin/echo "\nSuccessful to remove the temporary files." | /usr/bin/tee -a $LOG
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载