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

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 @ # $ %...
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/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...
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?
Create a bash script file named assessment-script-a that: 1. Accepts any number of file names on...
Create a bash script file named assessment-script-a that: 1. Accepts any number of file names on the command line 2. For each file name provided, delete any line that contains the string: qwe.rty When the changes are completed, the script should display the total number of files scanned, and the total number of files changed. Example Command: assessment-script-a file.a file.b file.c file.d file.e    Example Output: 5 files scanned, 3 files changed 3. Your script should include a series of...
Write a bash script to find all the files ending with .c recursively for every directory...
Write a bash script to find all the files ending with .c recursively for every directory in your current working directory, then copy each one to a folder called programs, need handle duplicates by appending the number to the end of the file (ex main.c main-1.c ) compile them and generate a report report should look like: main.c compiles prog2.c failed main-2.c compiles etc.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT