-
Notifications
You must be signed in to change notification settings - Fork 0
/
lec4vid2Parameters
executable file
·38 lines (27 loc) · 1.19 KB
/
lec4vid2Parameters
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
29
30
31
32
33
34
35
36
37
#!/bin/bash
# this script generates a random password for each user specified on the command line
#DIsplay what the user typed on the commandline ,Expands to the name of the shell or shell script.
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 them how many arguments they passed in
#inside the scripts they are parameters , outside they are arguments
NUMBER_OF_PARAMETERS="${#}"
echo "you supplied $NUMBER_OF_PARAMETERS arguments in the command line"
# make sure they supply atleast one argument
if [ $NUMBER_OF_PARAMETERS -lt 1 ]
then
echo "usage ${0} USER_NAME [USER_NAME] ..."
exit 1
fi
# Generate and Display username and password for each parameter [./lec4vid2Parameters jason mahi dhone]
for USER_NAME in ${@} #Expands to the positional parameters, starting from one. In contexts where word splitting is performed, this expands each positional parameter to a separate word 🚩️ Usage: help for | head
do
PASSWORD=$(date +%s%N | sha256sum | head -c14)
echo "$USER_NAME : $PASSWORD"
done
# For loop to print 1 to 50
for((i=1;i<=50;i++))
do
echo $i
done