<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-193  評論-715  文章-1  trackbacks-0
    本Blog所有內容不得隨意轉載,版權屬于作者所有。如需轉載請與作者聯系( fastzch@163.com )。
    未經許可的轉載,本人保留一切法律權益。
    一直以來,發現有某些人完全不尊重我的勞動成果,隨意轉載,提醒一下那些人小心哪天惹上官司。


    SecureCRT支持ActiveX script engines,包括VBScript和JScript (Microsoft’s version of JavaScript)兩種腳本。

    Note:如果你想使用腳本自動運行方式的話,需要在session?option中進行設置。

    腳本可以用任何文本編輯器來開發。Script頭部用來識別腳本語言和SecureCRT腳本接口的版本,腳本頭部的每一行必須以#開頭,頭部包括$language行和$interface行。例如,下面是一個簡單的腳本。
    #?$language?=?"VBScript"
    #?$interface?
    =?"1.0"

    Sub?Main
    ??
    '?Display?SecureCRT's?version
    ??MsgBox?"SecureCRT?version?is:?"?&?crt.Version
    End?Sub

    代碼通常放在main子過程,引擎在執行main子過程前,將轉換并執行全局代碼(腳本代碼定義在任何子過程之外),如果你有一些初始化處理的話,可以使用這一特性。

    如果想終止main過程,用VBScript的話,可以用Exit Sub語句。如:

    Sub?Main

    ??condition?
    =?DoSomething()
    ??
    If?condition?=?0?Then
    ????
    '?Error,?bailout
    ????Exit?Sub
    ??
    End?If
    ???
    End?Sub

    SecureCRT有一些內建的對象,可以通過頂級應用對象或子對象調用。這些對象都有一些屬性和方法。例如:

    Dim?dlg
    Set?dlg?=?crt.Dialog
    dlg.Prompt(
    "Login:")



    下面分享給大家一個通過N個跳板機上傳文件的FTP腳本:

    #$language?=?"VBScript"
    #$interface?
    =?"1.0"

    Sub?main
    ??
    '?turn?on?synchronous?mode?so?we?don't?miss?any?data
    ??crt.Screen.Synchronous?=?True
    ??
    ??
    '?Wait?for?a?string?that?looks?like?"login:?"?or?"Login:?"
    ??'?Occasionally,?a?host?needs?to?be?kicked?to?display?a
    ??'?login?prompt.
    ??
    ??
    If?(Not?crt.Screen.WaitForString("ogin:?",?5))?Then
    ????crt.Screen.Send?vbCr
    ????crt.Screen.WaitForString?
    "ogin:?"
    ??
    End?If
    ??
    ??crt.Screen.Send?
    "user0"?&?VbCr
    ??crt.Screen.WaitForString?
    "assword:"
    ??crt.Screen.Send?
    "pwd0"?&?VbCr
    ??crt.Screen.WaitForString?
    "#"
    ??crt.Screen.Send?
    "cd?/tmp"?&?VbCr
    ??crt.Screen.WaitForString?
    "#"
    ?
    ??
    'ftp?to?Machine1
    ??crt.Screen.Send?"ftp?IP1"?&?VbCr
    ??crt.Screen.WaitForString?
    "):?"
    ??crt.Screen.Send?
    "user1"?&?VbCr
    ??crt.Screen.WaitForString?
    "assword:"
    ??crt.Screen.Send?
    "pwd1"?&?VbCr
    ??crt.Screen.WaitForString?
    "ftp>?"
    ??filename?
    =?crt.Dialog.Prompt("Please?enter?your?filename.",?"Enter?filename",?"",?false)??
    ??crt.Screen.Send?
    "cd?/tmp"?&?VbCr
    ??crt.Screen.WaitForString?
    "ftp>?"
    ??crt.Screen.Send?
    "binary"?&?VbCr
    ??crt.Screen.WaitForString?
    "ftp>?"??
    ??crt.Screen.Send?
    "put?"?+?filename?&?VbCr
    ??crt.Screen.WaitForString?
    "ftp>?"
    ??crt.Screen.Send?
    "bye"?&?VbCr
    ??crt.Screen.WaitForString?
    "#"???


    ??crt.Screen.Send?
    "telnet?IP1"?&?VbCr
    ??
    ??
    If?(Not?crt.Screen.WaitForString("ogin:?",?5))?Then
    ????crt.Screen.Send?vbCr
    ????crt.Screen.WaitForString?
    "ogin:?"
    ??
    End?If
    ??
    ??crt.Screen.Send?
    "user1"?&?VbCr
    ??crt.Screen.WaitForString?
    "assword:"
    ??crt.Screen.Send?
    "pwd1"?&?VbCr
    ??crt.Screen.WaitForString?
    ">"
    ??crt.Screen.Send?
    "cd?/tmp"?&?VbCr
    ??crt.Screen.WaitForString?
    ">"
    ??
    ??
    ??
    ??
    'ftp?to?Machine2
    ??crt.Screen.Send?"ftp?IP2"?&?VbCr
    ??crt.Screen.WaitForString?
    "):?"
    ??crt.Screen.Send?
    "user2"?&?VbCr
    ??crt.Screen.WaitForString?
    "assword:"
    ??crt.Screen.Send?
    "pwd2"?&?VbCr
    ??crt.Screen.WaitForString?
    "ftp>?"
    ??
    ??crt.Screen.Send?
    "cd?/tmp"?&?VbCr
    ??crt.Screen.WaitForString?
    "ftp>?"
    ??crt.Screen.Send?
    "binary"?&?VbCr
    ??crt.Screen.WaitForString?
    "ftp>?"??
    ??crt.Screen.Send?
    "put?"?+?filename?&?VbCr
    ??crt.Screen.WaitForString?
    "ftp>?"
    ??crt.Screen.Send?
    "bye"?&?VbCr
    ??crt.Screen.WaitForString?
    ">"???


    ??crt.Screen.Send?
    "telnet?IP2"?&?VbCr
    ??
    If?(Not?crt.Screen.WaitForString("ogin:?",?5))?Then
    ????crt.Screen.Send?vbCr
    ????crt.Screen.WaitForString?
    "ogin:?"
    ??
    End?If
    ??crt.Screen.Send?
    "user2"?&?VbCr
    ??crt.Screen.WaitForString?
    "assword:"
    ??crt.Screen.Send?
    "pwd2"?&?VbCr
    ??crt.Screen.WaitForString?
    "#"
    ??crt.Screen.Send?
    "cd?/tmp"?&?VbCr
    ??crt.Screen.WaitForString?
    "#"
    ??
    ??
    ??
    ??
    ??
    ??
    ????
    'ftp??to?Machine3
    ??crt.Screen.Send?"ftp?IP3"?&?VbCr
    ??crt.Screen.WaitForString?
    "):?"
    ??crt.Screen.Send?
    "user3"?&?VbCr
    ??crt.Screen.WaitForString?
    "assword:"
    ??crt.Screen.Send?
    "pwd3"?&?VbCr
    ??crt.Screen.WaitForString?
    "ftp>?"
    ?
    ??crt.Screen.Send?
    "cd?/tmp"?&?VbCr
    ??crt.Screen.WaitForString?
    "ftp>?"
    ??crt.Screen.Send?
    "binary"?&?VbCr
    ??crt.Screen.WaitForString?
    "ftp>?"??
    ??crt.Screen.Send?
    "put?"?+?filename?&?VbCr
    ??crt.Screen.WaitForString?
    "ftp>?"
    ??crt.Screen.Send?
    "bye"?&?VbCr
    ??crt.Screen.WaitForString?
    "#"???


    ??crt.Screen.Send?
    "telnet?IP3"?&?VbCr
    ??
    ??
    If?(Not?crt.Screen.WaitForString("ogin:?",?5))?Then
    ????crt.Screen.Send?vbCr
    ????crt.Screen.WaitForString?
    "ogin:?"
    ??
    End?If
    ??
    ??crt.Screen.Send?
    "user3"?&?VbCr
    ??crt.Screen.WaitForString?
    "assword:"
    ??crt.Screen.Send?
    "pwd3"?&?VbCr
    ??crt.Screen.WaitForString?
    "#"
    ??crt.Screen.Send?
    "cd?/tmp"?&?VbCr
    ??crt.Screen.WaitForString?
    "#"
    ??
    ??
    ??
    ??
    ??
    ????
    'ftp??to?Machine4
    ??crt.Screen.Send?"ftp?IP4"?&?VbCr
    ??crt.Screen.WaitForString?
    "):?"
    ??crt.Screen.Send?
    "user4"?&?VbCr
    ??crt.Screen.WaitForString?
    "assword:"
    ??crt.Screen.Send?
    "pwd4"?&?VbCr
    ??crt.Screen.WaitForString?
    "ftp>?"

    ??crt.Screen.Send?
    "binary"?&?VbCr
    ??crt.Screen.WaitForString?
    "ftp>?"??
    ??crt.Screen.Send?
    "put?"?+?filename?&?VbCr
    ??crt.Screen.WaitForString?
    "ftp>?"
    ??crt.Screen.Send?
    "bye"?&?VbCr
    ??crt.Screen.WaitForString?
    "#"???


    ??crt.Screen.Send?
    "telnet?IP4"?&?VbCr
    ??
    ??
    If?(Not?crt.Screen.WaitForString("ogin:?",?5))?Then
    ????crt.Screen.Send?vbCr
    ????crt.Screen.WaitForString?
    "ogin:?"
    ??
    End?If
    ??
    ??crt.Screen.Send?
    "user4"?&?VbCr
    ??crt.Screen.WaitForString?
    "assword:"
    ??crt.Screen.Send?
    "pwd4"?&?VbCr
    ??crt.Screen.WaitForString?
    ">"
    ??
    ??
    ??crt.Screen.Synchronous?
    =?False

    End?Sub


    ?

    posted on 2008-09-29 12:51 Robin's Programming World 閱讀(9160) 評論(4)  編輯  收藏 所屬分類: 其它

    評論:
    # re: SecureCRT Script 學習筆記 2008-12-16 16:09 | 白雪
    這么好的文章怎么沒人支持呢?

    先頂一下再看!
      回復  更多評論
      
    # re: SecureCRT Script 學習筆記[未登錄] 2009-06-08 09:52 | randy
    確實是好東西,不過有沒有關于循環語句之類的范例?  回復  更多評論
      
    # re: SecureCRT Script 學習筆記 2009-08-23 16:33 | hmc
    好]
      回復  更多評論
      
    # re: SecureCRT Script 學習筆記 2009-11-05 19:36 | Learnero
    @randy
    關于循環語句之類的可以看下VBScript的教程。  回復  更多評論
      
    主站蜘蛛池模板: 免费久久精品国产片香蕉| 午夜毛片不卡免费观看视频| 亚洲精品一级无码鲁丝片 | 亚洲熟妇AV乱码在线观看| 国产成人免费午夜在线观看| 亚洲免费二区三区| 成人免费视频试看120秒| 亚洲国产AV一区二区三区四区| 久久夜色精品国产噜噜亚洲AV| 国产无遮挡无码视频免费软件| 亚洲成熟xxxxx电影| 最新黄色免费网站| 2020久久精品亚洲热综合一本| 精品国产呦系列在线观看免费| 毛茸茸bbw亚洲人| 三年片在线观看免费西瓜视频| 亚洲国产精品国自产拍电影| 久久WWW免费人成一看片| 亚洲精品456人成在线| 国产成人免费永久播放视频平台 | AV免费网址在线观看| 亚洲欧美乱色情图片| 亚洲人成无码网WWW| 中文字幕无码免费久久| 亚洲国产美女福利直播秀一区二区| 久久久久免费看黄A片APP| 免费无毒a网站在线观看| 亚洲乱码国产乱码精品精| 国产成人免费视频| 亚洲日本在线电影| 亚洲最大激情中文字幕| 国产乱子精品免费视观看片| 羞羞网站在线免费观看| 亚洲日本一区二区| 日韩免费电影在线观看| 国产永久免费高清在线| 亚洲午夜成人精品无码色欲| 永久亚洲成a人片777777| 永久免费毛片在线播放| 99精品视频在线观看免费| 国产成人精品日本亚洲11|