Question

The first script is validate.sh. This is a simple form validation script that will be used...

The first script is validate.sh. This is a simple form validation script that will be used to verify the inputs given. Normally, this would be done to validate input from a website or another program before entry into a database or other record storage. In this case, we will keep it simple and only focus on the input validation step. In particular, the script should prompt the user for four values: first name, last name, zip code, and email address. Each input must be validated, meaning that the input conforms to a certain standard. Here is the standard for this assignment:

The first name must start with a capital letter and contain only letters and hyphens.

The last name must start with a capital letter and contain only letters and hyphens.

The zip code must be exactly 5 digits and nothing else.

The email address must be a valid email address format, meaning USER@DOMAIN, where both USER and DOMAIN must be only letters, numbers, dots, underscores, and hyphens.

As the script reads each value, use regular expressions to ensure that the value matches the standard above. If a value does not match the standard, print an error message and exit immediately (don't prompt for the rest of the inputs). If all four values are validated successfully, then print a message indicating that fact. Here are some sample runs:

[user@localhost lab3]$ ./validate.sh

First name: R2-D2

First name must start with a capital letter and contain only letters and hyphens!

[user@localhost lab3]$ ./validate.sh

First name: Han

Last name: S0L0

Last name must start with a capital letter and contain only letters and hyphens!

[user@localhost lab3]$ ./validate.sh

First name: Han

Last name: Solo

Zip code: 12 parsecs

Zip code must be exactly 5 digits!

[user@localhost lab3]$ ./validate.sh

First name: Han

Last name: Solo

Zip code: 12345

Email address: han.solo

Email address must be USER@DOMAIN, where both USER and DOMAIN must be only letters, numbers, dots, underscores, and hyphens!

[user@localhost lab3]$ ./validate.sh

First name: Han

Last name: Solo

Zip code: 12345

Email address: [email protected]

Validated!

[user@localhost lab3]$

Once you've got it tested and working, TAKE SCREENSHOT 1 of the output of the script for a few sample runs. Only provide a single screenshot. More than one will be ignored. PLACE SCREENSHOT 1 HERE:

COPY AND PASTE your script into this box, for formatting (also note that if you submit in a separate file, you MUST include the start and end script lines below):

#START SCRIPT

#END SCRIPT

The second script for this assignment is find_and_replace.sh. You will need to use sed to replace all instances of one string in a file. Specifically, find_and_replace.sh should take 4 arguments. The first is the file to read from, the second is the file to output to, the third is the string to find, and the fourth is the replacement string. The script itself is relatively simple. The script must read every line from the input file no matter how many lines there are. It then replaces all instances of the first string given with the second string. Finally, it outputs every line to the output file whether or not any substitutions happened.

As always you need to do error checking. Specifically, check the number of arguments and that the first argument is actually a file. Note that you don't need to check if the second argument exists or because your script should output to that file either way. In addition, you'll need a way to send the input file in to a loop to read every line of that file. You can use I/O redirection with the entire loop. The same idea will be used to send the output of the loop to the output file. Here is some example output:

[user@localhost lab3]$ ./find_and_replace.sh

usage: find_and_replace.sh existing_file new_file current_string new_string

[user@localhost lab3]$ cat jedi_code

Jedi code:

There is no emotion, there is peace.

There is no ignorance, there is knowledge.

There is no passion, there is serenity.

There is no chaos, there is harmony.

There is no death, there is the Force.

[user@localhost lab3]$ ./find_and_replace.sh jedi_code jedi.out "is no" "ain't"

[user@localhost lab3]$ cat jedi.out

Jedi code:

There ain't emotion, there is peace.

There ain't ignorance, there is knowledge.

There ain't passion, there is serenity.

There ain't chaos, there is harmony.

There ain't death, there is the Force.

[user@localhost lab3]$

Once you've got it tested and working, TAKE SCREENSHOT 2 of the output of the script for a sample run. Only provide a single screenshot. More than one will be ignored. PLACE SCREENSHOT 2 HERE:

COPY AND PASTE your script into this box, for formatting (also note that if you submit in a separate file, you MUST include the start and end script lines below):

#START SCRIPT

#END SCRIPT

The third script is get_external_ip.sh, whose purpose is to find the public/external IP address that you are currently using to connect to the Internet. The IP address assigned to your laptop is almost certainly a private address, i.e., one that can't be used to communicate with other computers outside of your LAN. When your packets leave the LAN, a Network Address Translation device rewrites parts of your packets so that they get one of the public IP addresses that are available for your LAN. There are many websites that will tell your current public IP address, so we will use one of them to do this. Let's see that first:

Open up your web browser and go to: www.ipchicken.com

The web page will tell you your current public IP address.

Of course, web pages are just plain text HTML documents, and so we can write a script that downloads the web page and pulls out the IP address using a regex. There are many ways to think about the regular expression, but by far the simplest is to only match strings that look like IP addresses. To get started, use wget to download the webpage to a local file. Look through the file to find the IP address inside. Then use grep to search through the file for strings that look like IP addresses and only print those out. Of course, grep will print out the entire line that matches, but there is an option to grep that will have it only print out the actual matching string so you'll want to find that. Then, remove the downloaded file to clean up after yourself. Once you get the steps correct by hand, you can put them into the script which should be three lines long. Here is a sample run:

[user@localhost lab3]$ ./get_external_ip.sh

108.7.215.94

[user@localhost lab3]$

Once you've got it tested and working, TAKE SCREENSHOT 3 of the output of the script for a sample run. Only provide a single screenshot. More than one will be ignored. PLACE SCREENSHOT 3 HERE:

COPY AND PASTE your script into this box, for formatting (also note that if you submit in a separate file, you MUST include the start and end script lines below):

#START SCRIPT

#END SCRIPT

The final script is account_list.sh that is going to print a summary of some account information on your system. We've been looking at the /etc/passwd file on and off all semester. This script is going to parse that file to find and print the usernames for all non-system accounts. In addition, if the account has a non-standard (i.e., non-bash) shell, then the script will mark that username with an asterisk.

In particular, when you look at a line of /etc/passwd, there are seven colon-delimited fields. The first is the username, the third is the user ID, and the seventh is the shell for that user. Your script must ignore all system accounts, which are accounts that have a user ID of less than 1000. If the account has an ID of at least 1000, then you will print the username of that account. If the shell for that account is not /bin/bash, then also print an asterisk after the name to indicate that it is non-standard. Of course, you'll need to build in to the script to read from /etc/passwd with a while loop as we've seen before. Then you should be using awk to extract the appropriate fields from each line.

Here is a sample run:

[user@localhost lab3]$ ./account_list.sh     

nfsnobody*

username

[user@localhost lab3]$

Once you've got it tested and working, TAKE SCREENSHOT 4 of the output of the script for a sample run. Only provide a single screenshot. More than one will be ignored. PLACE SCREENSHOT 4 HERE:

COPY AND PASTE your script into this box, for formatting (also note that if you submit in a separate file, you MUST include the start and end script lines below):

#START SCRIPT

#END SCRIPT

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
The first script is validate.sh. This is a simple form validation script that will be used...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • The first script is validate.sh. This is a simple form validation script that will be used...

    The first script is validate.sh. This is a simple form validation script that will be used to verify the inputs given. Normally, this would be done to validate input from a website or another program before entry into a database or other record storage. In this case, we will keep it simple and only focus on the input validation step. In particular, the script should prompt the user for four values: first name, last name, zip code, and email address....

  • Python Coding The script, `eparser.py`, should: 1. Open the file specified as the first argument to...

    Python Coding The script, `eparser.py`, should: 1. Open the file specified as the first argument to the script (see below) 2. Read the file one line at a time (i.e., for line in file--each line will be a separate email address) 3. Print (to the screen) a line that "interprets" the email address as described below 4. When finished, display the total number of email addresses and a count unique domain names Each email address will either be in the...

  • How can I print the Database table in PHP please ? here I have form for name and email, also I have php code that allow...

    How can I print the Database table in PHP please ? here I have form for name and email, also I have php code that allow user to add his name and email to my database, all I need to print my final database when the user click on submit. <form action="" method="post"> <label>Name :</label> <input type="text" name="name" required="required" placeholder="Please Enter Name"/><br /><br /> <label>Email :</label> <input type="email" name="email" required="required" /><br/><br /> <input type="submit" value=" Submit " name="submit"/><br /> </form>...

  • I need help please to add function for clean up any inputs form that we receive from the users for this code below : &lt...

    I need help please to add function for clean up any inputs form that we receive from the users for this code below : <?php session_start(); // initializing variables $fname = ""; $lname = ""; $address = ""; $city = ""; $state = ""; $zip = ""; $email = ""; $phone = ""; $errors = array(); // connect to the database $db = mysqli_connect("localhost","root","password","db"); // REGISTER USER if (isset($_POST['reg_user1'])) { // receive all input values from the form $fname =...

  • For this code below, I need to add the form information to mysql when I click...

    For this code below, I need to add the form information to mysql when I click on submit, at the same time when I click on submit I need to move to another page like Welcome.php WITH NOTE THAT THE ENTERED INFORMATION NOW ALREADY IN DATABASE how can I male that with my code below? THANKS ................................................................................................................................................   <form method="POST"> <div class="container">    <label for="fname"><b>First Name</b></label> <input type="text" placeholder="Enter First Name" name="fname" required> <label for="lname"><b>Last Name</b></label> <input type="text" placeholder="Enter Last Name"...

  • write a script named word_counts.sh that prints out how many words are on each line of...

    write a script named word_counts.sh that prints out how many words are on each line of standard input, as well as the total number of words at the end. The script should take no arguments. Instead, the script must work by reading every line of standard input (using a while loop) and counting the number of words on each line separately. The script is intended to work with standard input coming from a pipe, which will most often come from...

  • I am using Linux and looking for the below scripts. Message script: the first script should...

    I am using Linux and looking for the below scripts. Message script: the first script should display the IP address, machine name and path to the script. (This addition will help me to find your script when I look for it on your server.) Pause script: the second script should pause for 30 seconds. By creating this script separate from the first, we can run it at boot up when a pause might be helpful (so the output from the...

  • NEED HELP with HTML with Javascript embedding for form validation project below. I have my code...

    NEED HELP with HTML with Javascript embedding for form validation project below. I have my code below but I'm stuck with validation. If anyone can fix it, I'd really appreciate. ****************************************************************************** CODE: <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html> <head> <title>Nice</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script> var textFromTextArea; function getWords(){ var text =...

  • I need to create a code based off of what the users first name and last...

    I need to create a code based off of what the users first name and last name are along with a random set of numbers no longer than 10 characters as the picture below demonstrate (Java language) Scenario: You have been appointed by the CS department to create a username generator to create CS email accounts automatically. The CS email will have the following format: [email protected]. Your username must have a limit of 10 characters. Your program, will provide three...

  • Create a folder named "TrainerApp". In that folder create the following files. Create a PHP file,...

    Create a folder named "TrainerApp". In that folder create the following files. Create a PHP file, "insert-user-form.php", with a form that has the following fields: - First Name (text) - Last Name (text) - Email (text) - Password (text) - Submit button Create another PHP file, "insert-exercise-form.php" with a form that has the following fields: - Exercise Name (text) - Description (text) - Demonstration Image (file) - Submit button Create another PHP file, "login-user-form.php" with a form that has the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT