トップ 差分 一覧 ソース 置換 検索 ヘルプ PDF RSS ログイン

TeraTermマクロでShellスクリプト実行

TeraTermマクロでShellスクリプト実行するためのマクロを載せておく

; *************************************
; 変数設定
; *************************************

; 接続先の設定
constr = "localhost:22 /ssh /auth=password /keyfile="
strconcat constr ' /user=***** /passwd=***** /I'

; 接続先の設定(鍵ファイルを使用する場合)
; constr = "localhost:22 /ssh /auth=publickey /keyfile="
; strconcat constr '鍵ファイルのパス'
; strconcat constr ' /user=ユーザー名 /passwd=鍵のフレーズ'
; 
; プロンプト待ち文字列
waitprompt  = '[*****@'
; 実行するシェル
shell  = '~/data/temp/compress.sh'

; *************************************
; 接続処理
; *************************************
connect constr

if result <> 2 then
 setexitcode 1
 call end
endif


; *************************************
; シェル実行
; *************************************
wait waitprompt
sendln "sh " shell

wait waitprompt
call getError

str2int exitcode inputstr
setexitcode exitcode

wait waitprompt
sendln "exit"
call end

; *************************************
; 終了処理
; *************************************
:end
 end
 return
 
; *************************************
; エラーコード取得(inputstr)
; *************************************
:getError
  setsync 1
  flushrecv
  sendln "echo $?"
  recvln
  recvln
  setsync 0
return

 

[カテゴリ: OS > Windows]
[カテゴリ: OS > Linux]

[通知用URL]



  • Hatenaブックマークに追加
  • livedoorクリップに追加
  • del.icio.usに追加
  • FC2ブックマークに追加

最終更新時間:2008年05月25日 22時57分17秒