在Debian上使用SecureCRT脚本有以下两种常用方法:
sudo apt-get install expect
。然后创建脚本文件,如securecrt_auto.sh
,添加内容#!/usr/bin/expect
,接着设置超时时间、获取参数,使用spawn
启动SecureCRT,send
发送命令,expect
等待执行完成。最后给脚本添加可执行权限chmod +x securecrt_auto.sh
,通过./securecrt_auto.sh <session> <username> <password> "<command>"
运行。import os
,然后通过os.system
执行相关命令。将脚本保存为.py
文件,在SecureCRT的“Options”>“Global Options”>“Startup”>“Scripts”中添加该脚本,连接远程服务器时脚本会自动执行。