-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspecial-parameters.sh
More file actions
28 lines (22 loc) · 855 Bytes
/
special-parameters.sh
File metadata and controls
28 lines (22 loc) · 855 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
# This scripts generates a random password for each user specified on the command line
# Display what the user typed on the command line
echo "You executed this command: ${0}"
# Display the path and filename of the script.
echo "You used $(dirname ${0}) as the path to the $(basename ${0}) script."
# Tell user how many arguments they passed in
# (Inside the script they are parameters, outside they are arguments.)
NUMBER_OF_PARAMETERS="${#}"
echo "You supplied ${NUMBER_OF_PARAMETERS} argument(s) on the command line."
# Make sure they at least supply one argument.
if [[ "${NUMBER_OF_PARAMETERS}" -lt 1 ]]
then
echo "Usage: ${0} USER_NAME [USER_NAME]..."
exit 1
fi
# Generate and display a password for each parameter.
for USER_NAME in "${@}"
do
PASSWORD=$(date +%s%N | sha256sum | head -c48)
echo "${USER_NAME}: ${PASSWORD}"
done