⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 recover.exp

📁 网络数据管理协议的开发
💻 EXP
字号:
#!/usr/local/bin/expect#                              -*- Mode: Tcl -*- # recover.exp# # Description     : Tests NDMP server recover functionality.# #                   usage: recover.exp local|tcp mover|data datahost ?moverhost?#                   where: local|tcp specifies the data connection type.#                          mover|data specifies whether the mover or data#                          server is responsible for initiating the data#                          connection.#                          datahost is the name of the host to recover data to.#                          moverhost is the name of the host that will #                          run the mover and read the data from tape.#                          moverhost is only used if the connection type is#                          tcp. If the connection type is local or moverhost#                          is not specified, then the data is read from the#                          datahost.##                   <datahost>.tcl and <moverhost>.tcl must must exist and#                   contain the system variable initializations appropriate#                   to the host. See system.tcl for an example.#                   Replace <datahost> and <moverhost> with actual hostnames.## Copyright (c) 1998 Intelliguard, Network Appliance. All Rights Reserved.## $Id: recover.exp,v 1.2 1998/02/16 21:08:13 tim Exp $# if {[llength $argv] < 3} {    puts "usage: $argv0 local|tcp mover|data datahost ?moverhost?"    exitn}switch -exact -- [lindex $argv 0] {    local { set connection_type local }    tcp   { set connection_type tcp }    default {	puts "usage: $argv0 local|tcp mover|data datahost ?moverhost?"	exit    }}switch -exact -- [lindex $argv 1] {    mover { set initiator mover }    data  { set initiator data }    default {	puts "usage: $argv0 local|tcp mover|data datahost ?moverhost?"	exit    }}	set data_host [lindex $argv 2]source $data_host.tclset data_auth_cmd $auth_cmdset data_recover_list $recover_listif {$connection_type == "local" || [llength $argv] < 4} {    set mover_host $data_host} else {    set mover_host [lindex $argv 3]    source $mover_host.tcl}set mover_auth_cmd $auth_cmdset mover_tape_device $tape_deviceset timeout 60# start the data serverspawn ../ndmpc -h $data_hostset data_id $spawn_idexpect {    -i $data_id -re "(Error)|(ERROR)" { exit }    -i $data_id "ndmpc>"}send -i $data_id "connect_open 3\r"expect {    -i $data_id -re "(Error)|(ERROR)" { exit }    -i $data_id "ndmpc>"}send -i $data_id "$data_auth_cmd \r"expect {    -i $data_id -re "(Error)|(ERROR)" { exit }    -i $data_id "ndmpc>"}# Create another NDMP connection for the mover if using a TCP connection# between the data server and the mover.if {$connection_type == "tcp"} {    spawn ../ndmpc -h $mover_host -p 10001    set mover_id $spawn_id    expect {	-i $mover_id -re "(Error)|(ERROR)" { exit }	-i $mover_id "ndmpc>"    }    send -i $mover_id "connect_open 3\r"    expect {	-i $mover_id -re "(Error)|(ERROR)" { exit }	-i $mover_id "ndmpc>"    }    send -i $mover_id "$mover_auth_cmd \r"    expect {	-i $mover_id -re "(Error)|(ERROR)" { exit }	-i $mover_id "ndmpc>"    }} else {    set mover_id $data_id}# Configure the mover and open the tape device.send -i $mover_id "mover_set_record_size 61440 \r"expect {    -i $mover_id -re "(Error)|(ERROR)" { exit }    -i $mover_id "ndmpc>"}send -i $mover_id "tape_open $mover_tape_device \r"expect {    -i $mover_id -re "(Error)|(ERROR)" { exit }    -i $mover_id "ndmpc>"}send -i $mover_id "tape_mtio rew \r"expect {    -i $mover_id -re "(Error)|(ERROR)" { exit }    -i $mover_id "ndmpc>"}# Establish the data connection between the mover and data server.if { $initiator == "mover" } {    send -i $data_id "data_listen $connection_type \r"    if { $connection_type == "local" } {	expect {	    -i $data_id -re "connect_addr LOCAL.*\n" { exp_continue }	    -i $data_id -re "(Error)|(ERROR)" { exit }	    -i $data_id "ndmpc>"	}    } else {	expect {	    -i $data_id -re "TCP (0x\[0-9a-f]*) (\[0-9]*).*\n" {		set ipaddr $expect_out(1,string)		set port $expect_out(2,string)	    }	    -i $data_id -re "(Error)|(ERROR)" { exit }	    -i $data_id "ndmpc>"	}    }} else {    send -i $mover_id "mover_listen write $connection_type \r"    if { $connection_type == "local" } {	expect {	    -i $mover_id -re "connect_addr LOCAL.*\n" { exp_continue }	    -i $mover_id -re "(Error)|(ERROR)" { exit }	    -i $mover_id "ndmpc>"	}    } else {	expect {	    -i $mover_id -re "TCP (0x\[0-9a-f]*) (\[0-9]*).*\n" {		set ipaddr $expect_out(1,string)		set port $expect_out(2,string)	    }	    -i $mover_id -re "(Error)|(ERROR)" { exit }	    -i $mover_id "ndmpc>"	}    }}if { $initiator == "mover" } {    if { $connection_type == "local" } {	send -i $mover_id "mover_connect write local \r"    } else {	send -i $mover_id "mover_connect write tcp $ipaddr $port \r"    }    expect {	-i $mover_id -re "(Error)|(ERROR)" { exit }	-i $mover_id "ndmpc>"    }} else {    if { $connection_type == "local" } {	send -i $data_id "data_connect local \r"    } else {	send -i $data_id "data_connect tcp $ipaddr $port \r"    }    expect {	-i $data_id -re "(Error)|(ERROR)" { exit }	-i $data_id "ndmpc>"    }}send -i $data_id "add_env DIRECT $direct \r"expect {    -i $data_id -re "(Error)|(ERROR)" { exit }    -i $data_id "ndmpc>"}foreach entry $data_recover_list {    send -i $data_id "add_nlist [lindex $entry 0] [lindex $entry 1] [lindex $entry 2] \r"    expect {	-i $data_id -re "(Error)|(ERROR)" { exit }	-i $data_id "ndmpc>"    }}set data_done 0set mover_done 0set doMoverStop 0set doDataStop 0set doTapeClose 0set checkDataDone 0set checkMoverDone 0send -i $data_id "data_start_recover dump \r"expect {    -i $data_id -re "Log: .*\n$" { exp_continue }        -i $any_spawn_id -re "(Error)|(ERROR)" {	send -i $data_id "exit\r"	if {$mover_id != $data_id} { send -i $mover_id "exit\r" }	exit    }    -i $any_spawn_id "ndmpc>" {	if {$doMoverStop} {	    send -i $mover_id "mover_stop \r"	    set doMoverStop 0	    set doTapeClose 1	    exp_continue	}		if {$doDataStop} {	    send -i $data_id "data_stop \r"	    set doDataStop 0	    set checkMoverDone 1	    exp_continue	}		if {$doTapeClose} {	    send -i $mover_id "tape_close \r"	    set doTapeClose 0	    set checkDataDone 1	    exp_continue	}	if {$checkDataDone} {	    if {$data_done == 1} { exit }	    set checkDataDone 0	    set mover_done 1	    # Wait for notification that data server has halted.	    exp_continue	}	if {$checkMoverDone} {	    if {$mover_done} { exit }	    set checkMoverDone 0	    set data_done 1	    # Wait for notification that mover has halted.	    exp_continue	}	exp_continue    }    -i $data_id -re "Received notify_data_read: offset:(\[0-9]*) len:(\[0-9]*).*\n" {	set read_offset $expect_out(1,string)	set read_length $expect_out(2,string)	send -i $mover_id "mover_read $read_offset $read_length \r"	exp_continue    }        -i $data_id -re "Received notify_data_halted.*\n$" {	send -i $data_id "data_get_state \r"	set doDataStop 1	exp_continue    }    -i $mover_id -re "Received notify_mover_halted.*\n$" {	send -i $mover_id "mover_get_state \r"	set doMoverStop 1	exp_continue    }    -i $mover_id -re "Received notify_mover_paused.*\n$" {	send -i $mover_id "mover_close \r"	exp_continue    }    timeout {	send -i $data_id "data_get_state\r"	send -i $mover_id  "mover_get_state\r"	exp_continue    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -