Chinaunix
标题:
有个脚本
[打印本页]
作者:
nonameboy
时间:
2006-01-26 10:57
标题:
有个脚本
今天改了一个脚本,用来实现两台主机通过scp复制文件without密码.
这个脚本是从以前的同事复制过来的,再修改一下.
改完以后,功能可以实现,问题是里面有些语句看不懂.
想请shell的高手帮忙看一下是什么意思. 谢谢.
#!/bin/bash
oracle_pw="password"
# Expect function for copying files using scp
function scp_expect
{
if [[ -n $1 && -n $2 ]]
then
read pw
host_name=${2#*.}
/usr/bin/expect <<%%
log_user 0
spawn scp $1 $2
expect {
"Are you sure you want to continue connecting" {
send -- "yes\r"
expect {
"password:" { send -- "$pw\r" }
"${1##*/} " { }
}
}
"password:" { send -- "$pw\r" }
"${1##*/} " { }
}
expect eof
%%
else
echo "Usage scp_expect [source] [target]"
fi
}
# Export scp_expect that it can be invoked when we switch to oracle.
typeset -xf scp_expect
su oracle -c "echo $oracle_pw | scp_expect oracle@host1:~oracle/*abc /tmp/"
复制代码
作者:
nonameboy
时间:
2006-01-27 14:50
自已顶.....
作者:
brittany
时间:
2006-01-27 15:14
大过年的见了贴字要顶!
作者:
johnsilver
时间:
2006-01-27 15:30
提示:
作者被禁止或删除 内容自动屏蔽
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2