Advertisement
Guest User

Untitled

a guest
Mar 5th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. _filename = 'user_pass.txt'
  2. _hostname = param2
  3. _username = ''
  4. _password = ''
  5. _config_file = 'TERATERM.ini'
  6. _config_path = 'E:\Documents\teraterm設定\'
  7.  
  8. ; リストファイルのopen
  9. fileopen _fhandle _filename 0
  10.  
  11. ; 指定したホスト名を含む行を検索する
  12. while 1
  13. filereadln _fhandle _line
  14. ; 行末までチェックした場合、ループを抜ける
  15. if result = 1 then
  16. break
  17. endif
  18. strsplit _line ','
  19. strcompare groupmatchstr1 _hostname
  20. ; ホスト名が一致した行を見つけたら、
  21. ; ユーザー/パスワード/設定ファイル名を変数に格納してする
  22. ; その後、ループを抜ける
  23. if result = 0 then
  24. _username = groupmatchstr2
  25. _password = groupmatchstr3
  26. _config_file = groupmatchstr4
  27. break
  28. endif
  29. endwhile
  30.  
  31. ; ファイルのclose
  32. fileclose _fhandle
  33.  
  34. ; ユーザー名の変数が空の場合、リストファイルから定義を見つけられなかったため、
  35. ; プロンプトでユーザー名とパスワードを入力してもらう
  36. strlen _username
  37. if result = 0 then
  38. _showmsg1 = 'Please enter username @'
  39. strconcat _showmsg1 _hostname
  40. inputbox _showmsg1 'Login'
  41. _username = inputstr
  42.  
  43. _showmsg2 = 'Please enter password of'
  44. strconcat _showmsg2 _username
  45. strconcat _showmsg2 '@'
  46. strconcat _showmsg2 _hostname
  47. passwordbox _showmsg2 'Login'
  48. _password = inputstr
  49.  
  50. endif
  51.  
  52. ; リストファイルの定義、もしくはプロンプトで入力した
  53. ; 情報をもとに、SSH接続を開始
  54. msg = _hostname
  55. strconcat msg ':22 /ssh /auth=password /user='
  56. strconcat msg _username
  57. strconcat msg ' /passwd='
  58. strconcat msg _password
  59. strconcat msg ' /F='
  60. ;strconcat msg '"'
  61. strconcat msg _config_path
  62. strconcat msg _config_file
  63. ;strconcat msg '"'
  64.  
  65. ; テスト用(接続パラメータが表示される)
  66. ; messagebox msg 'test'
  67.  
  68. connect msg
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement