daily pastebin goal
13%
SHARE
TWEET

Untitled

a guest Apr 27th, 2016 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; This is a macro for Tera Term
  2. ;
  3.  
  4. ;; ログインIP/ID/PW
  5. hostname = '172.30.37.189'
  6. username = 'hoge'
  7. password = 'foobar'
  8.  
  9. ;; ping コマンド
  10. ping_cmd = 'ping -c 5 172.30.37.159'
  11. ping_timeout = 30
  12. ping_retry_num = 3
  13.  
  14. ;; shutdown コマンド
  15. shutdown_cmd = 'ls -la'
  16.  
  17. ;; ログ設定
  18. logdir = 'C:\teraterm_log\'
  19. logfile = logdir
  20. strconcat logfile username
  21. strconcat logfile '@'
  22. strconcat logfile hostname
  23. getdate datetime '-%Y%m%d-%H%M%S'
  24. strconcat logfile datetime
  25. strconcat logfile '.log'
  26. ;logopen logfile 0 1
  27.  
  28. ;; プロンプト文字列(Wait 用)
  29. remote_prompt = "$"
  30.  
  31. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  32.  
  33.  
  34. ;; SSHログイン
  35. strconcat msg ':22 /ssh /2 /auth=password /user='
  36. strconcat msg username
  37. strconcat msg ' /passwd='
  38. strconcat msg password
  39. connect msg
  40.  
  41. ;; ログ記録開始
  42. logopen logfile 0 1
  43.  
  44. ;; ping
  45. ping_result = -1
  46.  
  47. for i 1 ping_retry_num
  48.   wait remote_prompt
  49.   sendln ping_cmd
  50.  
  51.   timeout = ping_timeout
  52.   waitregex ' 0% packet loss' ' 1?[0-9][0-9]% packet loss'
  53.  
  54.   if result=1 then
  55.     ;; ping が全て通ったら break
  56.     ping_result = 1
  57.     break
  58.   endif
  59.  
  60.   if i = ping_retry_num then
  61.     ;; ping 失敗
  62.     ping_result = -1
  63.   endif
  64. next
  65.  
  66. if ping_result = 1 then
  67.   messagebox 'ping が成功しました。' '通信成功'
  68. else
  69.   messagebox 'ping が成功しませんでした。再度実行してください。' '通信失敗'
  70. endif
  71.  
  72. yesnobox '停止しますか?' '確認'
  73. if result then
  74.   wait remote_prompt
  75.   sendln shutdown_cmd
  76.   wait remote_prompt
  77. endif
  78.  
  79. ;; ログ記録終了
  80. logclose
  81.  
  82. ;; 切断
  83. closett
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top