in reply to Problems with passwords
Well, you can't be that worried about the password if you are using Telnet. Anyone on the LAN will be able to sniff out the password relatively easy.
Your best case solution if you want to use telnet is to create a user on the device that has limited rights (if the device will allow it, what is the device?) this way your script can get stats or monitor things and the password is not as big of a deal if it is discovered as the user cannot make catastrophic changes.
Many devices these days allow SSH access, it is usually better to look into this sort of access, then you can use key based access and protect the keys on the local file system.
"Nothing is sure but death and taxes" I say combine the two and its death to all taxes!