Write a Bash script called pass check that has a single possible command line ar
ID: 652185 • Letter: W
Question
Write a Bash script called pass check that has a single possible command line argument, and makes a report about the validity of entries in passwd file. If no command line argument is given you should assume that /etc/passwd should be analyzed, otherwise the file specified should be used (more than one argument in an error). Each line of the file should be examined and the following errors detected if they exist:1)If the UID is greater than 500 then make sure the specified shell is listed in the /etc/shells file and the permissions of the home directory are 700.2)If the UID is 0 then make the username is root and the GID is 0.Make sure there are no duplicate UID
Explanation / Answer
#!/bin/bash
read -p "Enter Username: " username
read -ers -p "Enter New password for user $username: " paswd
echo
read -ers -p "Enter Root Password: " rpaswd
echo
password=`python file ${paswd}`;
echo "$username $password $npaswd"
cat host | while read line
do
#####expect####
status=$(expect -c "
spawn ssh $line usermod -p $password $username
expect {
password: { send "$rpaswd "; exp_continue }
}
exit
")
echo ""
echo "$status" > log.txt
#####end of expect#######
done
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.