Warning: Undefined variable $post in /home/d94d2eh6/infrapod.net/public_html/wp-content/themes/sango-theme-poripu/functions.php on line 12

Warning: Attempt to read property "ID" on null in /home/d94d2eh6/infrapod.net/public_html/wp-content/themes/sango-theme-poripu/functions.php on line 12

Warning: Undefined array key 1 in /home/d94d2eh6/infrapod.net/public_html/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 12

Warning: Undefined array key 2 in /home/d94d2eh6/infrapod.net/public_html/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 15

Warning: Undefined array key 3 in /home/d94d2eh6/infrapod.net/public_html/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 18

Warning: Undefined array key 4 in /home/d94d2eh6/infrapod.net/public_html/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 21

Warning: Undefined array key 1 in /home/d94d2eh6/infrapod.net/public_html/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 24

Warning: Undefined array key 2 in /home/d94d2eh6/infrapod.net/public_html/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 27

Warning: Undefined array key 3 in /home/d94d2eh6/infrapod.net/public_html/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 30

Warning: Undefined array key 4 in /home/d94d2eh6/infrapod.net/public_html/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 33
本サイトはプロモーションを含みます。

Tera Termマクロでシリアルログインする方法


Warning: Undefined array key 1 in /home/d94d2eh6/infrapod.net/public_html/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 12

Warning: Undefined array key 2 in /home/d94d2eh6/infrapod.net/public_html/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 15

Warning: Undefined array key 3 in /home/d94d2eh6/infrapod.net/public_html/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 18

Warning: Undefined array key 4 in /home/d94d2eh6/infrapod.net/public_html/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 21

Warning: Undefined array key 1 in /home/d94d2eh6/infrapod.net/public_html/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 24

Warning: Undefined array key 2 in /home/d94d2eh6/infrapod.net/public_html/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 27

Warning: Undefined array key 3 in /home/d94d2eh6/infrapod.net/public_html/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 30

Warning: Undefined array key 4 in /home/d94d2eh6/infrapod.net/public_html/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 33

PCとネットワーク機器やサーバとシリアルケーブルで接続してログインする方法について解説します。

シリアルログイン(コンソールログイン)のやり方

まずはコードを見てください。

connect '/C=1'

シリアルポートの番号を引数で渡すだけです(サンプルでは1番)。最近はシリアルポートを搭載しているパソコンが少なく、きっと皆さんはUSBシリアルを使用しているかと思います。そうすると単純に1とか2にはならないと思うので、使用したいシリアルポートが何番なのか事前に調べておく必要があります。

ボーレートを指定する

TeraTermの初期設定ではシリアルポートのボーレートは9600となっています。通常はこれでも問題ないかと思いますが、BIG-IPのようにボーレートが19200に設定されている場合もありますので、必要に応じてボーレートを指定します。

connect '/C=1 /BAUD=19200'

Tera Termが対応していないボーレートを指定すると、このオプションは無視されます。

ログイン処理

telnetと同じようにログインプロンプトやパスワードプロンプトの処理をすべて自分で書かなくてはなりません。

connect '/C=1'

sendln
sendln

wait 'login'
sendln 'foo'
wait 'Password'
sendln 'router'

wait 'Router'

このサンプルはNEC製のIX2015というルーターへシリアル接続するTeraTermマクロです。

シリアル接続の面倒なところはシリアルログインしたままTeraTermを閉じるとログイン状態が保持されてしまうところです。ですので、シリアル接続したからといってログインプロンプトが表示されるとは限らず、もしかしたらパスワードプロンプトかも知れないし、既にログインしているかも知れません。では、そいういう場合に備えたTeraTermマクロを書いて見ましょう。

connect '/C=3'

sendln
pause 1

do
    wait 'login:' 'Passwaord:' 'Router#'
    if result == 1 then ;loginプロンプトが表示された場合
        sendln 'foo'
        continue
    elseif result == 2 then ;Passowrdプロンプトが表示された場合
        sendln 'router'
        continue
    endif
loop while result != 3 ;Router# という文字列を受信するまでループ

ループ処理が混じっていて少し難しいかも知れませんが「Router#」という文字列を受信するまでひたすらループしているだけです。後は「login:」という文字列を受信したらユーザー名を送信し「Password:」という文字列受信をしたらパスワードを送信しています。


Warning: Undefined array key 1 in /home/d94d2eh6/infrapod.net/public_html/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 12

Warning: Undefined array key 2 in /home/d94d2eh6/infrapod.net/public_html/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 15

Warning: Undefined array key 3 in /home/d94d2eh6/infrapod.net/public_html/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 18

Warning: Undefined array key 4 in /home/d94d2eh6/infrapod.net/public_html/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 21

Warning: Undefined array key 1 in /home/d94d2eh6/infrapod.net/public_html/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 24

Warning: Undefined array key 2 in /home/d94d2eh6/infrapod.net/public_html/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 27

Warning: Undefined array key 3 in /home/d94d2eh6/infrapod.net/public_html/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 30

Warning: Undefined array key 4 in /home/d94d2eh6/infrapod.net/public_html/wp-content/themes/sango-theme-poripu/library/functions/prp_content.php on line 33