Here is a case where sometime we need to send the files or receive files using sftp non-interactive mode.
Here lftp has been used to pass the credentials to sftp. agent.jar is a file locally available and We wanted it to copy to remote host 192.168.56.153.
Here is the code.
--------------
#!/bin/sh
HOST=192.168.56.153
USER=oracle
PASS=oracle
PORT=22
lftp -u ${USER},${PASS} sftp://${HOST}:${PORT} <<EOF
cd /home/oracle
put agent.jar
bye
EOF
echo "done"
-------------
put is for sending a file from local to remote and get is to receive a file from remote to local server. you need to change directory using cd and use put or get accordingly.
Hope this will help.
Here lftp has been used to pass the credentials to sftp. agent.jar is a file locally available and We wanted it to copy to remote host 192.168.56.153.
Here is the code.
--------------
#!/bin/sh
HOST=192.168.56.153
USER=oracle
PASS=oracle
PORT=22
lftp -u ${USER},${PASS} sftp://${HOST}:${PORT} <<EOF
cd /home/oracle
put agent.jar
bye
EOF
echo "done"
-------------
put is for sending a file from local to remote and get is to receive a file from remote to local server. you need to change directory using cd and use put or get accordingly.
Hope this will help.