#!/bin/bash
passwd="1234567"
echo "passwd:${passwd}"
rm -rf *.deb
expect -c "
spawn scp username@192.168.0.1:/home/username/*.deb ./
expect {
\"password\" {set timeout 500; send \"${passwd}\r\"; exp_continue;}
}
expect eof"
ls -lh ./*.deb
dpkg -r com.xxx.yyy
dpkg -i *.deb
对端:
用户名:username
密码:1234567
IP:192.168.0.1
文件:/home/username/com.xxx.yyy.deb
此shell脚本会自动scp com.xxx.yyy.deb到本机,并覆盖安装deb包,expect超时时间设置为500s。