how to handle output generated after execution of command/script on host unix machine?
Hi Experts, I am still struggling with handling output generated after execution of command/script on host unix machine using windows client machine ssh code : import sys import datetime import time # setup logging paramiko.util.log_to_file('darshak_simple.log') ssh=paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(*,username=,password=) try: stdin,stdout,stderr=ssh.exec_command(BsPlSMProbe -f node -d /var/log/Darshak/3.txt ) // output of this command will be store in /var/log/Darshak/ in remote machine except: {Issue is files are generating but remaining blank pls pls help me out of this} print check time.sleep(10) print stdout.readlines() a=stdout.readlines() print 1 ssh.close() #print stdout.readlines() Issue is files are generating but remaining blank pls pls help me out of this -- BR Darshak Bavishi -- BR Darshak Bavishi -- http://mail.python.org/mailman/listinfo/python-list
how tohandling output generated after execution of command/script on host unix machine?
Hi Experts, I am still struggling with handling output generated after execution of command/script on host unix machine using windows client machine ssh code : import sys import datetime import time # setup logging paramiko.util.log_to_file('darshak_simple.log') ssh=paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(*,username=,password=) try: stdin,stdout,stderr=ssh.exec_command(BsPlSMProbe -f node -d /var/log/Darshak/3.txt ) // output of this command will be store in /var/log/Darshak/ in remote machine except: {Issue is files are generating but remaining blank pls pls help me out of this} print check time.sleep(10) print stdout.readlines() a=stdout.readlines() print 1 ssh.close() #print stdout.readlines() Issue is files are generating but remaining blank pls pls help me out of this -- BR Darshak Bavishi -- http://mail.python.org/mailman/listinfo/python-list
How to install pycrypto mode in windows ?!
Hi Experts , I am using python 2.6 and i had installed paramiko module which needs pycrypto but , when i am installing pycrypto in windows its giving error as follows: creating build\lib.win32-2.6\Crypto\PublicKey copying .\PublicKey\DSA.py - build\lib.win32-2.6\Crypto\PublicKey copying .\PublicKey\ElGamal.py - build\lib.win32-2.6\Crypto\PublicKey copying .\PublicKey\pubkey.py - build\lib.win32-2.6\Crypto\PublicKey copying .\PublicKey\qNEW.py - build\lib.win32-2.6\Crypto\PublicKey copying .\PublicKey\RSA.py - build\lib.win32-2.6\Crypto\PublicKey copying .\PublicKey\__init__.py - build\lib.win32-2.6\Crypto\PublicKey running build_ext building 'Crypto.Hash.MD2' extension error: Unable to find vcvarsall.bat can u suggest any source to get pycrypto to avoid such events?! -- BR Darshak Bavishi -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there any way to SSH from Python ?!
Hi, I have downloaded paramiko and installed it now it needs Pycrypto . So i tried to install pycrypto but its giving error of vcvarsall.bat so from christian suggestion i downloaded MinGW . But i have no idea how to install it in windows machine pls help me out of this!! On Mon, Dec 13, 2010 at 5:04 PM, Felipe Vinturini felipe.vintur...@gmail.com wrote: On Mon, Dec 13, 2010 at 3:11 AM, Darshak Bavishi bavishi.dars...@gmail.com wrote: i am trying from last week but no luck !! one thing only found that pexpect it not useful in windows pls help out of this On Mon, Dec 13, 2010 at 10:39 AM, Chris Rebert c...@rebertia.com wrote: On Sun, Dec 12, 2010 at 9:03 PM, Darshak Bavishi bavishi.dars...@gmail.com wrote: Hi Experts, I need to know that is there any way to SSH (From Windows Host) to Unix machine ?! If Yes than How ? http://www.lag.net/paramiko/ Did you try googling ssh python? Cheers, Chris -- http://blog.rebertia.com -- BR Darshak Bavishi -- http://mail.python.org/mailman/listinfo/python-list Hi! Here is a good link about SSH and paramiko: http://jessenoller.com/2009/02/05/ssh-programming-with-paramiko-completely-different/ Regards, Felipe. -- BR Darshak Bavishi -- http://mail.python.org/mailman/listinfo/python-list
AttributeError while running ssh (from windows) paramiko need help
Hi Experts , while i am running following demo ssh script of paramiko -- *import base64* *import getpass* *import os* *import socket* *import sys* *import traceback* * * *import paramiko* *import interactive* * * * * *# setup logging* *paramiko.util.log_to_file('demo_simple.log')* * * *# get hostname* *username = ''* *if len(sys.argv) 1:* *hostname = sys.argv[1]* *if hostname.find('@') = 0:* *username, hostname = hostname.split('@')* *else:* *hostname = raw_input('Hostname: ')* *if len(hostname) == 0:* *print '*** Hostname required.'* *sys.exit(1)* *port = 22* *if hostname.find(':') = 0:* *hostname, portstr = hostname.split(':')* *port = int(portstr)* * * * * *# get username* *if username == '':* *default_username = getpass.getuser()* *username = raw_input('Username [%s]: ' % default_username)* *if len(username) == 0:* *username = default_username* *password = getpass.getpass('Password for %...@%s: ' % (username, hostname))* * * * * *# get host key, if we know one* *hostkeytype = None* *hostkey = None* *try:* *host_keys = paramiko.util.load_host_keys(os.path.expanduser('~/.ssh/known_hosts'))* *except IOError:* *try:* *# try ~/ssh/ too, because windows can't have a folder named ~/.ssh/ * *host_keys = paramiko.util.load_host_keys(os.path.expanduser('~/ssh/known_hosts'))* *except IOError:* *print '*** Unable to open host keys file'* *host_keys = {}* * * *if host_keys.has_key(hostname):* *hostkeytype = host_keys[hostname].keys()[0]* *hostkey = host_keys[hostname][hostkeytype]* *print 'Using host key of type %s' % hostkeytype* * * * * *# now, connect and use paramiko Transport to negotiate SSH2 across the connection* *try:* *t = paramiko.Transport((hostname, port))* *t.connect(username=username, password=password, hostkey=hostkey)* *chan = t.open_session()* *chan.get_pty()* *chan.invoke_shell()* *print '*** Here we go!'* *print* *interactive.interactive_shell(chan)* *chan.close()* *t.close()* * * *except Exception, e:* *print '*** Caught exception: %s: %s' % (e.__class__, e)* *traceback.print_exc()* *try:* *t.close()* *except:* *pass* *sys.exit(1)* It gives error as follows : *Warning (from warnings module):* * File C:\Python26\lib\site-packages\Crypto\Hash\SHA.py, line 6* *from sha import ** *DeprecationWarning: the sha module is deprecated; use the hashlib module instead* * * *Warning (from warnings module):* * File C:\Python26\lib\site-packages\Crypto\Hash\MD5.py, line 6* *from md5 import ** *DeprecationWarning: the md5 module is deprecated; use hashlib instead* *Hostname: 10.135.15.41* *Username [admin]: root* * * *Warning (from warnings module):* * File C:\Python26\lib\getpass.py, line 88* *return fallback_getpass(prompt, stream)* *GetPassWarning: Can not control echo on the terminal.* *Warning: Password input may be echoed.* *Password for r...@10.135.15.41: alcatel* Unable to open host keys file* Here we go!* * * *Line-buffered terminal emulation. Press F6 or ^Z to send EOF.* * * * * * * *Last login: Mon Dec 13 19:38:31 2010 from 10.135.19.50* * * * * Caught exception: type 'exceptions.AttributeError': read* *Traceback (most recent call last):* * File C:\Python26\paramiko-1.7.4\demos\demo_simple.py, line 90, in module* *interactive.interactive_shell(chan)* * File C:\Python26\paramiko-1.7.4\demos\interactive.py, line 36, in interactive_shell* *windows_shell(chan)* * File C:\Python26\paramiko-1.7.4\demos\interactive.py, line 91, in windows_shell* *d = sys.stdin.read(1)* * File C:\Python26\lib\idlelib\rpc.py, line 560, in __getattr__* *raise AttributeError, name* *AttributeError: read* * * * * EOF * * *Traceback (most recent call last):* * File C:\Python26\paramiko-1.7.4\demos\demo_simple.py, line 101, in module* *sys.exit(1)* *SystemExit: 1* * * *can you tell me what is use of Hostkey and how to overcome this issue?!* -- BR Darshak Bavishi -- http://mail.python.org/mailman/listinfo/python-list
Is there any way to SSH from Python ?!
Hi Experts, I need to know that is there any way to SSH (From Windows Host) to Unix machine ?! If Yes than How ? Because when i use telenet it not showing the no result !! As earlier it was suggested that i should try with exit first and than read_all() but still issue persist and getting hang import getpass import sys import telnetlib import time HOST = *.*.*.* #user = raw_input(Enter your remote account: ) #password = getpass.getpass() user = Darshak2 password = tn = telnetlib.Telnet(HOST , 5400) print 1 tn.read_until(login: , 5) print 2 tn.write(user + \n) print 3 if password: tn.read_until(Password: ) tn.write(password + \n) print 4 tn.write(set alarm = off + \n) tn.write(set event = off + \n) print 5 tn.write(Cd /Office-Parameters/Mobility-Config-Parameters/Subscriber-Query-by-IMSI-MSISDN-or-IMEI + \n) print 6 tn.write(\n) tn.write(\n) tn.write(vlrsubquery msisdn=*** + \n) tn.write(\n) tn.write(exit + \n) print tn.read_all() tn.close() -- BR Darshak Bavishi -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there any way to SSH from Python ?!
i am trying from last week but no luck !! one thing only found that pexpect it not useful in windows pls help out of this On Mon, Dec 13, 2010 at 10:39 AM, Chris Rebert c...@rebertia.com wrote: On Sun, Dec 12, 2010 at 9:03 PM, Darshak Bavishi bavishi.dars...@gmail.com wrote: Hi Experts, I need to know that is there any way to SSH (From Windows Host) to Unix machine ?! If Yes than How ? http://www.lag.net/paramiko/ Did you try googling ssh python? Cheers, Chris -- http://blog.rebertia.com -- BR Darshak Bavishi -- http://mail.python.org/mailman/listinfo/python-list
how to read o/p of telenet (python) ?!
hi experts , i have code to telnet remote machine (unix) i am using port 5400 to telnet but o/p is not in visible format when i run random commands or run when i give as read_some() it displays some lines but in case of read_all() it gets hang !! In actual i want to get some string from o/p and process pls help [code] import getpass import sys import telnetlib import time HOST = hostname #user = raw_input(Enter your remote account: ) #password = getpass.getpass() user = hostname password = ABC tn = telnetlib.Telnet(HOST , 5400) print 1 print 2 tn.write(user + \n) print 3 if password: tn.read_until(Password: ) tn.write(password + \n) print 4 tn.write(set alarm = off + \n) tn.write(set event = off + \n) print 5 tn.write(Cd /Office-Parameters/ + \n) print 6 tn.write(\n) tn.write(\n) tn.write(vlrsubquery msisdn=*** + \n) tn.write(\n) print tn.read_all() tn.write(exit + \n) tn.close() -- BR Darshak Bavishi -- http://mail.python.org/mailman/listinfo/python-list
stuck with Pexpect script need help!!
Hi Experts, got ready made code for ssh to unix using python host machine is windows now when i run this its gives following error : * Traceback (most recent call last): File C:\Python26\pexpect-2.1\pexpect-2.1\pxssh.py, line 1, in module from pexpect import * File C:\Python26\pexpect-2.1\pexpect-2.1\pexpect.py, line 83, in module Pexpect is intended for UNIX-like operating systems.) ImportError: No module named resource A critical module was not found. Probably this operating system does not support it. Pexpect is intended for UNIX-like operating systems. RESTART Traceback (most recent call last): File C:\Python26\ssh_session.py, line 7, in module from pexpect import * ImportError: No module named pexpect * Can we use pexpect from windows host machine ?! -- BR Darshak Bavishi -- http://mail.python.org/mailman/listinfo/python-list