if [ “$#” -ne 5 ]
then

echo “Parameter strength is not supporting. “$@” is not matching for the required pattern: SOURCE_MACHINE SOURCE_PATH DESTINATION_MACHINE DESTINATION_PATH IS_FILE_TRANSFER_SRC_TO_DEST(0 – SOURCE to Destination, 1 – Destination to source, 2 – remote to remote)”

  exit 1
fi

Source Machine & Files details.

SOURCE_MACHINE=$1
SOURCE_PATH=$2

Source Machine & Files details.

DESTINATION_MACHINE=$3
DESTINATION_PATH=$4
FTP_ACCOUNT=ftpaccount

#Defines execution purpose
IS_FILE_TRANSFER_SRC_TO_DEST=$5

#COMMANDS TO USE
SCP=scp
SCP_OPTIONS=-r

case “$IS_FILE_TRANSFER_SRC_TO_DEST” in

             “0”)

echo “Local to Remote file transfer.”
$SCP $SCP_OPTION $SOURCE_PATH $FTP_ACCOUNT@$DESTINATION_MACHINE:$DESTINATION_PATH

;;

“1”)

echo “Remote to Local file transfer.”
$SCP $SCP_OPTION $FTP_ACCOUNT@$SOURCE_MACHINE:$SOURCE_PATH $DESTINATION_PATH

;;

   “2”)

echo “Remote to Remote file transfer.”
$SCP $SCP_OPTION $FTP_ACCOUNT@$SOURCE_MACHINE:$SOURCE_PATH $FTP_ACCOUNT@$DESTINATION_MACHINE:$DESTINATION_PATH
 

   ;;

*)

echo “Invalid option for fifth param, range should be 0 -2 (0 – SOURCE to Destination, 1 – Destination to source, 2 – remote to remote)”

;;

esac

Advertisements