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.