Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _filename = 'user_pass.txt'
- _hostname = param2
- _username = ''
- _password = ''
- _config_file = 'TERATERM.ini'
- _config_path = 'E:\Documents\teraterm設定\'
- ; リストファイルのopen
- fileopen _fhandle _filename 0
- ; 指定したホスト名を含む行を検索する
- while 1
- filereadln _fhandle _line
- ; 行末までチェックした場合、ループを抜ける
- if result = 1 then
- break
- endif
- strsplit _line ','
- strcompare groupmatchstr1 _hostname
- ; ホスト名が一致した行を見つけたら、
- ; ユーザー/パスワード/設定ファイル名を変数に格納してする
- ; その後、ループを抜ける
- if result = 0 then
- _username = groupmatchstr2
- _password = groupmatchstr3
- _config_file = groupmatchstr4
- break
- endif
- endwhile
- ; ファイルのclose
- fileclose _fhandle
- ; ユーザー名の変数が空の場合、リストファイルから定義を見つけられなかったため、
- ; プロンプトでユーザー名とパスワードを入力してもらう
- strlen _username
- if result = 0 then
- _showmsg1 = 'Please enter username @'
- strconcat _showmsg1 _hostname
- inputbox _showmsg1 'Login'
- _username = inputstr
- _showmsg2 = 'Please enter password of'
- strconcat _showmsg2 _username
- strconcat _showmsg2 '@'
- strconcat _showmsg2 _hostname
- passwordbox _showmsg2 'Login'
- _password = inputstr
- endif
- ; リストファイルの定義、もしくはプロンプトで入力した
- ; 情報をもとに、SSH接続を開始
- msg = _hostname
- strconcat msg ':22 /ssh /auth=password /user='
- strconcat msg _username
- strconcat msg ' /passwd='
- strconcat msg _password
- strconcat msg ' /F='
- ;strconcat msg '"'
- strconcat msg _config_path
- strconcat msg _config_file
- ;strconcat msg '"'
- ; テスト用(接続パラメータが表示される)
- ; messagebox msg 'test'
- connect msg
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement