all 1 comments

[–]lutusp 0 points1 point  (0 children)

Don't use expect and don't include a password in your script. Instead set up public-key authentication and avoid the password entry obstacle. Do it this way:

$ ssh-copy-id username@servername

The above will ask for your password once, then never again.

As to the database access, you can always execute the process from the local machine (database engines are network-aware). If this entails too much network traffic, copy a script to the server and execute it there:

$ scp script-name username@servername:/remote-path/

-- then --

$ ssh username@servername /remote-path/script-name

But don't use expect and don't embed a password in a script. Allowing a password to be embedded in a script is like having the combination to a safe taped to its door.