Obviously you do not want to add your Username/Password to scripts so how can you enter those and make use of execute_cmd and sftp_file without them?  Simple provide them as command line arguments in your master script that organizes all the steps.

#!/bin/bash
usage() {
        echo "Usage: $0 [-u <username>] [-p <passwrd>]" 1>&2
        echo "-u Intranet Password" 1>&2
        echo "-p Intranet Password" 1>&2
        exit 1
 }

while getopts "u:p:" o; do
    case "${o}" in
        u)
            username=${OPTARG}
            ;;
        p)
            password=${OPTARG}
            ;;
        *)
            usage
            ;;
    esac
done

shift $((OPTIND-1))

if [ "$samepwd" = true ] ; then
        ftppassword=${password}
        ftpid=${username}
fi

if [ -z "${username}" ] || [ -z "${password}" ]; then
    usage
fi

echo Username: ${username}
echo Passsword: ${password}

Usage:  command_name  -u -p

Now you can extend this out, and when I get a chance I’ll do another post on how to add additional arguments to this script.


Discover more from GhostProgrammer - Jeff Miller

Subscribe to get the latest posts sent to your email.

By Jeffery Miller

I am known for being able to quickly decipher difficult problems to assist development teams in producing a solution. I have been called upon to be the Team Lead for multiple large-scale projects. I have a keen interest in learning new technologies, always ready for a new challenge.