so I'm currently working with an AWS server project, and I'm trying to figure out how to automate the downloading of this file from AWS. In the MacOS terminal, I can write the individual lines of code that would a) log me in and b) manually grab the file, but I've been working on creating a shell script that would automate it, which ends up resulting in an illegal response/option message when I tried running the shell.
This server I'm working with, I have a private PEM key assigned to my user. I usually log in with SFTP.
I tried running something like this
/usr/local/bin/expect <<EOF
Spawn sftp -I /Users/path/to/private.PEM username@hostname
Expect "sftp"
Send "cd /tmp"
Expect "sftp>"
Send "get SQL.sql /path/local/Desktop"
Expect "sftp"
Send "Done"
EOF
I'm pretty sure my code has many errors, as I had kinda copy pasta'd a supposedly working solution with my details. End goal would be to log into the AWS, download this file, and ideally load it directly into my database. Trying to figure out the best way to do this, thank you!