The most common way I have seen to automate/script use of a program that is interactive (e.g. asks for a password, provides a command prompt, etc.) is to use
expect. You can make a standalone expect script or you can
embed an expect script within a bash script. For instance:
Code:
#!/bin/bash
echo "Bash script about to invoke ftp with expect"
/bin/cat << EOF | /usr/bin/expect
spawn /usr/bin/ftp
expect "ftp> "
send "open\r"
expect "(to) "
send "xxx.xxx.xx.xx\r"
# and so on
interact
EOF
echo "Bash script call to ftp through expect complete. Continuing with additional processing"