I'm particularly new to shell scripting and ssh commands and such. I was wondering if I could automate simple sftp prompts when uploading/downloading files from one server to another.
Here is what I do:
I essentially want to automate this since I'll be calling a script which will upload a file from my source server to a remote one through an InfoSphere Datastage sequence job on the source server.
PS. Pardon my insolence if this question doesn't make sense of if it's too juvenile :)
check out expect, that helps to automate such issues in scripts.
Here a sample that works for me:
#!/usr/bin/expect -f
set timeout 30
set user "coder"
set node "repohost"
set fsrc "/home/coder/Sources/sysperf/makefile"
set fdst "/tmp"
set uspw "topSecret"
spawn sftp $user@$node:$fsrc $fdst
expect_after eof {exit 1}
expect "$user@$node's password: " {send "$uspw\r"}
expect "*100%*"