
from twisted.conch import error from twisted.conch.ssh import transport, connection, keys, userauth, channel, common from twisted.internet import defer, protocol, reactor import re import Tkinter from Tkinter import * from tkMessageBox import * from os.path import exists from Tkinter import * import commands #from DT import demo import shutil from os.path import exists import ftplib import sys from ftplib import FTP from tkMessageBox import * from tkFileDialog import asksaveasfilename import string from os import popen from re import split import Tkinter import os win = Tkinter.Tk(); Label(win,text='CARD UPLOAD UTILITY').pack(side=TOP) #btn=Tkinter.Button(win,text='LIST ALL SUB FILES',command =(lambda : slist())) #btn.pack(side=BOTTOM) def submit(): login=textlog.get() password=textpass.get() if login=="" or password=="": showinfo('ERROR','PLEASE FILL THE NECESSARY DETAILS ') elif login=='m' and password=='m': print 'HELLO USER' top.withdraw()#closes current window import sys, getpass server = '10.144.17.2' command = 'ls -l' username = 'cteam' password = 'cteam' factory = ClientCommandFactory( username, password, command) reactor.connectTCP(server, 22, factory) reactor.run( ) class ClientCommandTransport(transport.SSHClientTransport): def __init__(self, username, password, command): self.username = username self.password = password self.command = command print "username",username print "password",password print "command",command def verifyHostKey(self, pubKey, fingerprint): # in a real app, you should verify that the fingerprint matches # the one you expected to get from this server return defer.succeed(True) def connectionSecure(self): self.requestService( PasswordAuth(self.username, self.password, ClientConnection(self.command))) class PasswordAuth(userauth.SSHUserAuthClient): def __init__(self, user, password, connection): userauth.SSHUserAuthClient.__init__(self, user, connection) self.password = password def getPassword(self, prompt=None): return defer.succeed(self.password) class ClientConnection(connection.SSHConnection): def __init__(self, cmd, *args, **kwargs): connection.SSHConnection.__init__(self) self.command = cmd def serviceStarted(self): self.openChannel(CommandChannel(self.command, conn=self)) class CommandChannel(channel.SSHChannel): name = 'session' def __init__(self, command, *args, **kwargs): channel.SSHChannel.__init__(self, *args, **kwargs) self.command = command def channelOpen(self, data): self.conn.sendRequest( self, 'exec', common.NS(self.command), wantReply=True).addCallback( self._gotResponse) def _gotResponse(self, _): self.conn.sendEOF(self) def dataReceived(self, data): #self.dat=date print "nenu",data dat=data #print"nenu1",dat lis(dat) def lis(m): Label(win,text='%s'%m).pack(side=TOP) dirfm = Frame(win) dirsa=Scrollbar(dirfm) dirsb= Scrollbar(dirfm) dirsb.pack(side = RIGHT, fill =Y) dirs = Listbox(dirfm,height = 50, width = 70, yscrollcommand = dirsb.set) textsfile = Entry(dirfm) def closed(self): reactor.stop( ) print "nenuclose" #print"nenu" ,data[56] #print"nenu" ,data[57] #print"nenu" ,data[58] #print"nenu" ,data[59] #print"nenu" ,data[63] '''p=1 for i in range(40,100): if(data[i]=='-' or data[i]=='x'): p=i print"nenu" ,data[p-9] #ClientCommandFactory(username, password, command) #__init__(self, username, password, command)''' class ClientCommandFactory(protocol.ClientFactory): def __init__(self, username, password, command): self.username = username self.password = password self.command = command def buildProtocol(self, addr): protocol = ClientCommandTransport( self.username, self.password, self.command) return protocol if __name__ == "__main__": top = Tkinter.Tk() #to draw Label in the main page label = Tkinter.Label(top, text=' CARD UPLOAD UTILITY ' ) label.pack() #to draw Label label = Tkinter.Label(top, text='ENTER LOGIN ') label.pack(side=LEFT,fill=X) #to draw Textbox tv = Tkinter.StringVar( ) textlog=Entry(top,width=20,textvariable=tv) textlog.pack(side=LEFT) #to draw Label label = Tkinter.Label(top, text=' ENTER PASSWORD ') label.pack(side=LEFT) #to draw Textbox tv1 = Tkinter.StringVar( ) textpass=Entry(top,width=20,textvariable=tv1) textpass.pack(side=LEFT) #to draw submit submit=Tkinter.Button(top, text=' SUBMIT ',command=submit) submit.pack(side=LEFT) top.bind_all('<Return>',(lambda event: submit())) #to draw Quit quit = Tkinter.Button(top, text=' QUIT ',command=top.quit) quit.pack(side=LEFT) Tkinter.mainloop() #put m as username and m as password On Tue, Sep 30, 2008 at 9:12 PM, shweta mani <shweta3230@gmail.com> wrote:
hi friends thanks for immediate reply. i have referred the book twisted.......... currently i am facing the problem. i have to show ls -l output in a listbox using Tkinter but because of TCP it first stores information in a window or some packet format. so it doesnot show the output in a continuous manner.
On Tue, Sep 30, 2008 at 2:07 AM, Jack Whitham <jack-tp@cs.york.ac.uk>wrote:
On Sun, Sep 28, 2008 at 02:11:49AM +0200, paul wrote:
Hope this isn't too offensive but last time I checked conch didn't work on win32 (http://twistedmatrix.com/trac/ticket/50). I guess most users would be happy with a basic "secure RPC" implementation, no console stuff. No idea how much work that is though ...
Conch does work on Win32, I have written an application that uses it (not the command line client). You have to install pycrypto in addition to Twisted.
-- Jack Whitham jack@cs.york.ac.uk
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python