EE - I have an Expect program developed as part of the remote management of several hundred servers. This script has a list of remote servers to manage, and for each server, it starts and ssh session, logs in to the remote server, transfers a shell script, runs it, and captures the results. The shell script it transfers can do pretty much anything, so this can be used for things as diverse as adding or deleting a user, locking or unlocking an account, OS patching operations, gathering statistics from all servers, or software deployment/configuration, or security scanning/auditing. This Expect program transfers its shell script in exactly the same way as the ftp-inband example that comes with Expect. The method, step by step, is this:
- Locally, uuencode the file to be sent, into a temporary file.
- Send a remote command "cat > remote_temporary_file".
- Locally, read the temporary file.
- Send the uuencoded data to the remote end, where cat will receive the data and write it to the remote temporary file.
- send an EOF signal.
- Send a remote command "uudecode remote_temporary_file".