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

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...
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...
Task 1: Getting familiar with Unix commands Questions: How do you remove a directory and all...
Task 1: Getting familiar with Unix commands Questions: How do you remove a directory and all of its contents, including any subdirectories and files, without using rmdir repeatedly?         [5 Points] Go to your home directory (i.e. /home/) and enter the following command: ls -ali Explain the output. You need to clearly what each column specifies, what are the values in each column means. Also explain how it is different from: ls -li    [5 Points] How will you copy directory (not...
Object-Oriented Design and Patterns in Java (the 3rd Edition Chapter 5) - Create a directory named...
Object-Oriented Design and Patterns in Java (the 3rd Edition Chapter 5) - Create a directory named as the question number and save the required solutions in the directory. - Each problem comes with an expected tester name. In the directory for a given problem, including the tester and all java classes successfully run this tester. Exercise 5.2 ObserverTester.java - Improve Exercise 1 by making the graph view editable. Attach a mouse listener to the panel that paints the graph. When...
Create a file named work.sh in your hw5 directory. Give this file read and write permission...
Create a file named work.sh in your hw5 directory. Give this file read and write permission (no execute permissions) for you alone. No other account should have any access privileges to this file. Change the permissions on the work.sh file so you have read and write permissions. Give everybody else, including the group, read permissions only. Give yourself read, write and execute permissions to the file work.sh. Give everyone else, including the group, execute permissions only. Create a directory named...
PLEASE USE LINUX/UNIX 1.Use either pico, vi, or cat to create the following file and name...
PLEASE USE LINUX/UNIX 1.Use either pico, vi, or cat to create the following file and name it as “mysedfile”: Name Class1 Class2 Class3 Tom 92 94 88 Nancy 91 85 95 Lisa 99 77 96 Jerry 84 98 90 2. Please use sed command(s) to complete the following tasks. display Tom’s record. display Lisa’s record. display both Tom’s and Lisa’s records. remove the blank line(s) from “mysedfile.” replace all the digits with *.
Task: 2.1 : Shell Scripting Task1 :Traditional hello world script Open terminal create Lab01 directory and...
Task: 2.1 : Shell Scripting Task1 :Traditional hello world script Open terminal create Lab01 directory and use cd command to move into the directory Open a new file script hello.sh using vi editor # vi hello.sh Type the following lines #!/bin/bash           echo Hello World     Save the file and return back to terminal How to Runhello.sh Adding Execute Permission Checking current permission        # ls -la hello.sh Adding Execute permission # chmod u+x hello.sh   Check whether execute permission is added # ls...
PYTHON PROGRAM Requirements: 1. Create an empty directory a variable named song_search 2. Repeatedly prompt the...
PYTHON PROGRAM Requirements: 1. Create an empty directory a variable named song_search 2. Repeatedly prompt the user to enter either the title of a song or enter nothing if they have no more songs to enter 3. For each song title entered by the user, split the song title into words by using the split function and splitting on a space. For each word from each song title, ensure the song_search dictionary has a entry with that word as the...
Linux Directories, File Properties, and the File System in C Understanding Unix/Linux Programming Your version of...
Linux Directories, File Properties, and the File System in C Understanding Unix/Linux Programming Your version of mv command The mv command is more than just a wrapper around the rename system call. Write a version of mv that accepts two argument. The first argument must be the name of a file, and the second argument may be the name of a file or the name of a directory. If the destination is the name of a directory, then mv moves...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT