Question

In: Computer Science

UNIX/LINUX SCRIPT: Create a named directory and verify that the directory is there by listing all...

UNIX/LINUX SCRIPT:

Create a named directory and verify that the directory is there by listing all its contents.

Write a shell script to validate password strength. Here are a few assumptions for the password string.  

Length – a minimum of 8 characters.

• Contain alphabets , numbers , and @ # $ % & * symbols.

• Include both the small and capital case letters.

give a prompt of Y or N to try another password and displays an error if anything other than an N or Y is entered.

-If the password doesn’t comply to any of the above conditions, then the script should report it as a “Weak Password” otherwise display a “Strong Password”

If the password is Strong then the strong password will be added to a separate file named password.txt

and lastly display their contents of the password file, then delete the file and the directory and verify both are deleted.

Solutions

Expert Solution

The Shell Script is used in linux OS.

#!/bin/bash
echo "enter the password" //asking users to enter the password
read password //reads the password.
len="${#password}" //initialising the strength

if test $len -ge 8 ; then //applying the password validation in if else loop.

echo "$password" | grep -q [0-9] //grep command is used to search for all the possibility and we are telling users to including the numerical values and the A-Z alphabets

if test $? -eq 0 ; then

echo "$password" | grep -q [A-Z]

if test $? -eq 0 ; then

echo "$password" | grep -q [a-z]

if test $? -eq 0 ; then

echo "$password" | grep -q [$,@,#,%]

if test $? -eq 0 ; then
  
echo "Strong password"

else

echo "weak password include special characters"
  
fi   

else

echo "weak password include lower case character"

fi
else

echo "weak password include capital character"

fi
else

echo "please include the numbers in password it is weak password"   

fi

else

echo "password length should be greater than or equal 8 hence weak password"

fi


Expert Solution

#!/bin/bash

while true; do

        echo "Enter password:"

        read pwd

        length="${#pwd}"

        if test $length -ge 8; then

                echo "$pwd" | grep -q [a-zA-Z0-9]

                if test $? -eq 0; then

                        echo "$pwd" | grep -q ["@$#%&*"]

                        if test $? -eq 0; then

                                echo "Strong Password"

                                echo "$pwd" >> Passwords/password.txt

                        else

                                echo "Weak Password"

                        fi

                else

                        echo "Weak Password"

                fi

        else

                echo "Weak Password"

        fi

        read -p  "Try another password(Y or N):" option

        case "$option" in

             N ) break;;

             Y ) ;;

             * ) echo "enter valid option";;

        esac

done

Output


Related Solutions

Part II: gdb (Debugging under Unix) create a new directory named by Inlab6Part2 enter the directory...
Part II: gdb (Debugging under Unix) create a new directory named by Inlab6Part2 enter the directory Inlab6Part2 create a file named by reverse_new.c with the following contents: /*reverse.c */ #include <stdio.h> void reverse(char *before, char *after); main() {       char str[100];    /*Buffer to hold reversed string */       reverse("cat", str); /*Reverse the string "cat" */       printf("reverse(\"cat\")=%s\n", str); /*Display result */       reverse("noon", str); /*Reverse the string "noon" */       printf("reverse(\"noon\")=%s\n", str); /*Display result */       } void reverse(char *before,...
LINUX/UNIX Create a script named favcolor.sh. Take 2 parameters, 1. Username, 2. Favorite color. Print any...
LINUX/UNIX Create a script named favcolor.sh. Take 2 parameters, 1. Username, 2. Favorite color. Print any sentence on console using these 2 parameters.
Write a script named numberlines.py. This script creates a program listing from a source program. This...
Write a script named numberlines.py. This script creates a program listing from a source program. This script should: Prompt the user for the names of two files. The input filename could be the name of the script itself, but be careful to use a different output filename! The script copies the lines of text from the input file to the output file, numbering each line as it goes. The line numbers should be right-justified in 4 columns, so that the...
Write a script in C that will do the following : 1. Create the directory ZHW3....
Write a script in C that will do the following : 1. Create the directory ZHW3. 2. Verify that the directory is created by display all information related to the directory and not just the name of the directory. 3. Assume that the input from the command is used to validate password strength. Here are a few assumptions for the password string. • Length – minimum of 8 characters. • Contain alphabets , numbers , and @ # $ %...
unix/Linux Create a tar command using the man command and the link referred to in To...
unix/Linux Create a tar command using the man command and the link referred to in To Practice and Explore: Text File Utilities #9. Preliminaries Use the man pages to learn more about tar Review the links referred to in To Practice and Explore: Text File Utilities #9 to see examples of using tar command Perform Use tar "to stuff" three files and then "unstuff" them into a new directory. Include the -v option. Task ll to show the original 3...
Linux Use touch to create a file in your working directory called PutFileHere this is a...
Linux Use touch to create a file in your working directory called PutFileHere this is a linux question i acidentally put javascript when i first submitted it
Unix Create a script that will declare an array and assign four values from the command...
Unix Create a script that will declare an array and assign four values from the command line. 1. Use these four values - Paul, Ringo, George, John, - in that order 2. Display the content of the array, displaying the values in this format and this order The first array value is "John" The second array value is "Paul" The third array value is "George" The fourth array value is "Ringo"
Move the file “nfile2” into the “unix” directory. Copy the file “nfile1” into the “java” directory....
Move the file “nfile2” into the “unix” directory. Copy the file “nfile1” into the “java” directory. Show how you would create the files “test1”, “test2”, & “test3” in the “test” directory to ensure that they have the same file creation date/time. From the ~ folder, use the * and then the [ ] wildcard procedures to list all the files in the “test” directory. From the directory structure above, give an example of a relative path & an absolute path....
1. Compare the Unix directory and the windows directory and answer the following: a. Match 3...
1. Compare the Unix directory and the windows directory and answer the following: a. Match 3 Unix directories to a Windows directory that is similar in function. Briefly describe their similarities and differences. b. Find a directory in Unix that appears to have no equivalent in Windows. What does it do? c. Find a directory in Windows that appears to have no equivalent in Unix. What does it do?
What are control structures in Linux/Unix?
What are control structures in Linux/Unix?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT