###質問
pythonの学習でsshランチャ?を作っています。
ランチャからIP、ユーザ名、パスワードを取得して、
それをもとにteratermマクロで実行してログインする想定です。
IPアドレスの入力フィールドで、プルダウン内の値を選択しSSH接続を行うと、
接続後、一定時間プロンプトが帰ってきません。
フィールド内へ手動でIPアドレスを入力した場合は、
即座にプロンプトが帰ってきます。
こちらの原因を教えていただけますでしょうか。
python
1#問題箇所 2element_array = ["192.168.10.10\n","192.168.11.20\n"] 3text_ip = wx.ComboBox(panel, -1, choices=element_array, style=wx.CB_DROPDOWN)
###ソースコード
python
1#ソース全体 2 3import wx 4import os 5 6 7 8def button_push(event): 9 #初期化 10 clear_txt = open(u'tmp_ip.txt', 'w') 11 clear_txt.write("") 12 clear_txt.close() 13 14 clear_txt = open(u'tmp_username.txt', 'w') 15 clear_txt.write("") 16 clear_txt.close() 17 18 clear_txt = open(u'tmp_password.txt', 'w') 19 clear_txt.write("") 20 clear_txt.close() 21 22 #テキストを抽出 23 input_text_ip = text_ip.GetValue() 24 input_text_u = text_username.GetValue() 25 input_text_p = text_password.GetValue() 26 ip_C = input_text_ip.split(".") 27 check = "True" 28 #IPの確認とIPの抽出 29 if len(ip_C) == 4: 30 for ip in ip_C: 31 ip = int(ip) 32 if ip >= 0 and ip <= 255: 33 check = "True" 34 else : 35 check = "False" 36 wx.MessageBox('IP address error', 'Info') 37 else: 38 wx.MessageBox('IP address error', 'Info') 39 check = "False" 40 41 #tmpファイルにデータを入力 42 if check == "True": 43 ip_f = open(u'tmp_ip.txt', 'w') 44 ip_f.write(input_text_ip) 45 ip_f.close() 46 47 #ユーザ名とパスワードを抽出 48 name_f = open(u'tmp_username.txt', 'w') 49 name_f.write(input_text_u) 50 name_f.close() 51 52 password_f = open(u'tmp_password.txt', 'w') 53 password_f.write(input_text_p) 54 password_f.close() 55 56 #teratermのマクロ起動 57 cmd = "login.ttl" 58 os.system(cmd) 59 60 61app = wx.App() 62frame = wx.Frame(None, -1, u'sshログイン', size=(250, 170)) 63#透明度設定 64#frame.SetTransparent(210) 65#背景にパネルを設置 66panel = wx.Panel(frame,-1) 67 68layout = wx.BoxSizer(wx.VERTICAL) 69 70layout01 = wx.BoxSizer(wx.HORIZONTAL) 71s_text_ip = wx.StaticText(panel, -1, u"IPアドレス") 72layout01.Add(s_text_ip,0, wx.RIGHT, 8) 73 74element_array = ["192.168.10.10\n","192.168.11.20\n"] 75text_ip = wx.ComboBox(panel, -1, choices=element_array, style=wx.CB_DROPDOWN) 76 77#text_ip = wx.TextCtrl(panel,-1) 78 79layout01.Add(text_ip ,wx.RIGHT, 8) 80layout.Add(layout01, 0, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 10 ) 81layout.Add((-1,5)) 82 83 84layout02 = wx.BoxSizer(wx.HORIZONTAL) 85s_text_username = wx.StaticText(panel, -1, u"ユーザ名") 86layout02.Add(s_text_username, 0, wx.RIGHT, 13) 87text_username = wx.TextCtrl(panel,-1) 88layout02.Add(text_username,1) 89layout.Add(layout02, 0, wx.EXPAND | wx.LEFT | wx.RIGHT, 10 ) 90 91layout.Add((-1,5)) 92 93layout03 = wx.BoxSizer(wx.HORIZONTAL) 94s_text_password = wx.StaticText(panel, -1, u"パスワード") 95layout03.Add(s_text_password, 0, wx.RIGHT, 8) 96text_password = wx.TextCtrl(panel,-1) 97layout03.Add(text_password, 1) 98layout.Add(layout03, 0, wx.EXPAND | wx.LEFT | wx.RIGHT, 10 ) 99 100layout.Add((-1,5)) 101 102layout04 = wx.BoxSizer(wx.HORIZONTAL) 103button_1 = wx.Button(panel, -1, u"接続",size=(70,30)) 104layout04.Add(button_1, 0, ) 105layout.Add(layout04, 0, wx.ALIGN_RIGHT | wx.RIGHT ,10) 106 107button_1.Bind(wx.EVT_BUTTON, button_push) 108 109 110panel.SetSizer(layout) 111frame.Show() 112app.MainLoop() 113
login.ttl
fileopen USER 'tmp_username.txt' 0 filereadln USER username fileclose USER fileopen PASS 'tmp_password.txt' 0 filereadln PASS password fileclose PASS fileopen IP 'tmp_ip.txt' 0 filereadln IP hostname fileclose IP msg = hostname strconcat msg ':22 /ssh /auth=password /user=' strconcat msg username strconcat msg ' /passwd=' strconcat msg password connect msg

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/09/13 23:21
2016/09/14 03:41
2016/09/14 14:46
2016/09/14 22:47
2016/09/16 10:45 編集
2016/09/20 21:32
2016/09/22 06:49
2016/09/22 13:24
2016/09/28 16:09