Buongiorno a tutti. Tramite python (utilizzando l'esempio presente sulla documentazione della libreria telnetlib) riesco a connettermi, tramite telnet, al mio router.
Ecco il codice del mio file "test.py" import getpass import sys import telnetlib HOST = "192.168.1.2" user = raw_input("Utente: ") password = getpass.getpass() tn = telnetlib.Telnet(HOST) tn.read_until("login: ") tn.write(user + "\n") if password: tn.read_until("Password: ") tn.write(password + "\n") tn.write("help \n") tn.write("exit\n") print tn.read_all() Così facendo, mi vengono forniti tutti i possibili comandi che posso lanciare. ~ # help Built-in commands: ------------------- . : break cd chdir continue eval exec exit export false hash help local pwd read readonly return set shift source times trap true type ulimit umask unset wait [ [[ ash cat chgrp chmod chown cp date dd df echo egrep false fgrep free grep halt ifconfig insmod kill killall klogd ln login ls lsmod mesg mkdir modprobe more mv netstat nslookup ping pivot_root poweroff ps pwd reboot rm rmdir rmmod route sh sleep sync syslogd tail telnetd test tftp top touch traceroute true uname uptime vi watch wget who whoami Non riesco a capire come funziona il "write": - scrive tutto quanto e poi, una volta lanciato read_all esegue e legge i risultati - esegue il comando fornito e il read_all legge solamente i risultati?? E' per capire come poter fare un ping (per esempio) Grazie
_______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python