0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

TeraTermマクロ Tips

Posted at

recvlnについて

recvln1つではエコーバックの分を受け取ってしまうようです。
他の出力を受信してしまう場合もあります。
確実にやるなら、目印を付けてwaitlnでそこまで待つ、というのがいい思います

; 待機用文字列「wait:」を入れて改行してやる
sendln "ll | grep admin | sed -n 's/.*sudo\(.*admin\).*/wait:\n\1/p'"
; エコーを読み捨てる
recvln
; 待機用文字列を待つ
waitln 'wait:'
; 本命の文字列を読み取る
recvln

VER = inputstr
sendln 'echo ' VER
messagebox inputstr 'title'
# コマンド
ll | grep admin | sed -n 's/.*sudo\(.*admin\).*/wait:\n\1/p'
# 実行結果
wait:
_as_admin

ウィンドウを閉じて新しいウィンドウを開くマクロ


USER = 'user'
PASSWORD = 'password'
HOST = 'host'

sprintf2 ver '%s:22 /ssh /auth=password /user=%s /passwd=%s' HOST USER PASSWORD
connect ver

wait "$ "

; 処理

; ウィドウを閉じる、マクロは非リンク状態になる
closett


; 新しいウィンドウが開く
USER = 'user'
PASSWORD = 'password'
HOST = 'host'

sprintf2 ver '%s:22 /ssh /auth=password /user=%s /passwd=%s' HOST USER PASSWORD
connect ver

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?