I assume this is obvious, but if you do it this way, be sure that the permissions on /tmp/secret only allow read and write access to the file's owner and be sure that the file's owner is root.
Good point Don. A better location would be one that only root can access like /root assuming the permissions are restrictive 700. Feeding encrypted passwords to a command like chpasswd(8) would also be better. That way there are no plain text passwords on the target servers.