[Tutor] passwords in scripts

Ben Vinger benvinger at yahoo.co.uk
Tue Jan 24 00:02:42 CET 2006

Hi Danny

The Unix servers are ancient HP-UX ones.  I doubt if
an SSH implementation for them exists, but it is not
worth my while trying to find out, because I will not
be allowed to install anything on them (or even
suggest it).  So I access them using telnetlib:

host = 'hpserver'
user = 'backupuser\r'
password = 'backuppassword\r'
telnetConnection = telnetlib.Telnet(host)
telnetConnection.read_until('login: ')
telnetConnection.read_until('Password: ')
menu = telnetConnection.read_until('Please Enter
choice :')

etc - doing the things programatically what I would
have done if I opened a regular telnet session

On the  Windows servers the scheduled task I use runs
with my domain logon credentials.   This is fine for
the majority of the servers, but some are in other
domains where my  credentials don't do the job. For
them, I just open a connection to the ipc$ share in
advance, like so:

os.system(r'net use \\farserver\ipc$ 
/u:fardomain\administrator farpassword')

The information about all the backup results is
finally served as a single web page, so anyone can see
at a glance whether the backups worked. This can also
easily be emailed out, or warnings can be sent.

But surely my problem is a very common one.  Every
web-app must supply a username and password to make a
connection to its backend database, for example.


--- Danny Yoo <dyoo at hkn.eecs.berkeley.edu> wrote:

> I guess one question might be: why are the passwords
> there in the first
> place?  *grin*
> It's usually a good idea to try avoiding hardcoding
> things in a program,
> and that goes for passwords too.  If you're using
> passwords to connect to
> the Unix servers, you might want to consider looking
> at Keychain:
>     http://www.gentoo.org/proj/en/keychain/
> to avoid having to do manual password entry. 
> Alternatively, 'ssh' can
> be used to run remote commands on a Unix server. 
> There's a good example
> of this here:
>     http://www.jdmz.net/ssh/
> If you could tell us more details on why those
> passwords are there, we
> might have some better suggestions.
> Good luck!
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com

More information about the Tutor mailing list