I am trying to automate the file transfer or FTP from one server to the other.
#!/bin/bash
### In this model, the same filename is processed on each run.
### A timestamp is added to the result file and data file is copied to the archive or error folder with a timestamp after processing.
# Set current directory
cd `dirname "$0"`
# Set the environment variables
. ./Environment.sh $0
#######################################################################################################
#
#######################################################################################################
FILE=/hcm/Inbound/file.csv
sshpass -p 'xyz' sftp -oBatchMode=no -b - -oStrictHostKeyChecking=no [email protected] <<_EOF_
cd /upload/
put $FILE
_EOF_
# Exit
exit $?
When I am executing this shell script I am getting the following error in putty :
-bash: sshpass: command not found
I tried using the ssh passwordless method by ssh-keygen -t dsa
and other steps but I cannot access putty of the second server due to which I am not being able to execute the next steps.
Kindly help
exit $?
is completely redundant:exit
passes through the exit status of the immediately prior command by default. Also, you're missing a fair bit of quoting here -- which shellcheck.net will identify. – Flapper