Python Forum
Start Putty into Python Form
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Start Putty into Python Form
#3
Hi Gribouillis,

Thank you for your help,

I have write this code but i don't know how i can redirect my ssh session into my textbox.
I use Paramiko at the line 38.

import tkinter as tk
from tkinter import *
from tkinter import ttk
from tkinter import Menu
import paramiko
import subprocess
import sys
from paramiko_expect import SSHClientInteraction

form = tk.Tk()
form.title("SSHClient")
form.geometry("1000x700")
form.rowconfigure(0, weight=1)
form.rowconfigure(1, weight=1)
form.rowconfigure(2, weight=1)
form.rowconfigure(3, weight=25)
form.columnconfigure(0, weight=1)
form.columnconfigure(1, weight=4)
form.columnconfigure(2, weight=1)
form.columnconfigure(3, weight=4)
form.columnconfigure(4, weight=1)
form.columnconfigure(5, weight=4)
form.columnconfigure(6, weight=1)
form.columnconfigure(7, weight=1)

def NewTab(arg1, arg2):
    def wrap():
        tabServeur = ttk.Frame(tab_parent)
        tab_parent.add(tabServeur, text=TxtServer.get())
        tabServeur.rowconfigure(0, weight=1)
        tabServeur.columnconfigure(0, weight=1)
        #Process = subprocess.Popen('C:\\plink.exe -ssh [email protected] -pw screencast -P 32772',stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        TxtTerm = Text(tabServeur)
        TxtTerm.grid(sticky=W+E+N+S,row=0, column=0, padx=5, pady=5)
        TxtTerm.configure(bg='Black', fg='White')
        client = paramiko.SSHClient()
        client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        client.connect(hostname='IP', username='root', password='pwd', port='22')

    return wrap



#Création des boutons
ConnectButton = Button(form, text='Connect', command=NewTab('arg1', 'arg2'))
ConnectButton.grid(row=1, column=0, columnspan=27,
               sticky=W+E+N+S, padx=5, pady=5)

Label(form, text="Server :").grid(row=0, column=0)
Label(form, text="User :").grid(row=0, column=2)
Label(form, text="Password :").grid(row=0, column=4)
Label(form, text="Port :").grid(row=0, column=6)

TxtServer = Entry(form)
TxtServer.grid(row=0, column=1, sticky=W+E, padx=5, pady=5)
TxtUser = Entry(form)
TxtUser.grid(row=0, column=3, sticky=W+E, padx=5, pady=5)
TxtPassword = Entry(form, show="*")
TxtPassword.grid(row=0, column=5, sticky=W+E, padx=5, pady=5)
TxtPort = Entry(form)
TxtPort.grid(row=0, column=7, sticky=W+E, padx=5, pady=5)

#Création des onglets
tab_parent = ttk.Notebook(form)
tab_parent.grid(row=2, column=0, columnspan=27, rowspan=2,
               sticky=W+E+N+S, padx=5, pady=5)

menu = Menu(form)
form.config(menu=menu)
new_item = Menu(menu, tearoff=0)
new_item.add_command(label='Open Keepass')
new_item.add_command(label='Reload')
new_item.add_separator()
new_item.add_command(label='Exit', command=form.quit)
menu.add_cascade(label='File', menu=new_item)
form.config(menu=menu)

form.mainloop()
I have already try to launch putty on a external window, but my target is to have a SSH Shell with tab.

Thank You

Schlazen
Reply


Messages In This Thread
Start Putty into Python Form - by Schlazen - Mar-20-2020, 10:23 AM
RE: Start Putty into Python Form - by Gribouillis - Mar-20-2020, 11:13 PM
RE: Start Putty into Python Form - by Schlazen - Mar-23-2020, 01:51 PM
RE: Start Putty into Python Form - by Gribouillis - Mar-23-2020, 03:31 PM
RE: Start Putty into Python Form - by Schlazen - Mar-25-2020, 03:03 PM
RE: Start Putty into Python Form - by divya130 - Dec-13-2022, 06:28 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Idle won't start totalmachine 9 5,670 Oct-16-2022, 05:57 PM
Last Post: totalmachine
  readline.parse_and_bind() does not work in start-up script of Python interpreter zzzhhh 0 2,163 Jan-18-2022, 11:05 AM
Last Post: zzzhhh
  Error creating database with python and form? shams 3 3,283 Aug-02-2021, 02:00 PM
Last Post: deanhystad
  Error using mariadb select query with form in python? shams 2 2,832 Jul-29-2021, 12:30 PM
Last Post: shams
  html, python, a simple form test 1 2,560 Aug-09-2020, 01:59 PM
Last Post: snippsat
  Reading text from Putty window Nil 5 11,260 Jul-23-2020, 10:27 AM
Last Post: HritikaMehta
  Use Python to start/stop a server service via a webform? oakleaf2001 0 2,189 Apr-04-2020, 06:14 AM
Last Post: oakleaf2001
  Python 3.8 on mac failing to start sgandon 0 3,718 Jan-14-2020, 10:58 AM
Last Post: sgandon
  How to get first 5 images form the document using Python BeautifulSoup sarath_unrelax 0 2,029 Dec-19-2019, 07:13 AM
Last Post: sarath_unrelax
  How to update libc6 with Putty SSH? drogontargaryen 1 2,443 Jul-20-2019, 03:35 PM
Last Post: ndc85430

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020