Skip navigation.

极湖

无不用其“极”

Posts tagged with "secureCRT,JavaScript"

让 secureCRT 定时发送命令的脚本

,

想让secureCRT在一定时间后发送命令,为此做了一个脚本如下:
var startTime = (new Date()).getTime();
var afterSeconds = 60;
var executed = false;

function main() {
    crt.Screen.Send("date\n");
    while(!executed) {
        sendCommand();
    }
}

function sendCommand() {
    if((new Date()).getTime() > (startTime + (afterSeconds*1000))) {
        crt.Screen.Send("echo It is time to execute command\n");
        crt.Screen.Send("date\n");
        executed = true;
    }
}

保存成文件,然后通过菜单 script -> Run 选择该文件即可。
January 2010
S M T W T F S
December 2009February 2010
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30