Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can someone help me with this two part assignment, I'm so confused. You must implement all programs using Perl. You must enable the strict pragma

can someone help me with this two part assignment, I'm so confused.

You must implement all programs using Perl. You must enable the strict pragma and the warnings pragma (put use strict and use warnings at the top of your Perl source code). Otherwise, points will be deducted. Part I (50 points). In this problem, you will need to sort a list of lowercase character strings according to the following ordering rules. In the following, let str1 and str2 be two strings. Let vow1 be the substring of vowels appearing in str1, and vow2 the corresponding substring of str2. (Characters in vow1 and vow2 appear in the same order as they appear in str1 and str2, respectively.) If the substring vow1 appears before vow2 in the ascending ASCII order, str1 appears before str2 in the output. As an example, the vowel substring of the string apparate is aaae. If, after considering the above rule, there are ties among strings, break ties using the regular ascending ASCII order of the original strings str1 and str2. Your program should read the strings from a file (given as the command-line argument). In this file, each line contains one string. Your program should print the results to the standard output, one string per line. An example run of the program is given below. duan@linprog4 (~...homework/solutions) % perl sort_strings.pl sort_string.input apparate fanfare panacea albatross albacore false parmesan candelabra beans vermeil duan@linprog4 (~...homework/solutions) % Part II. (50 points) In our lecture, we discussed a simple echo server and echo client, where the client can only send a single line to the server, and the server is implemented as a sequential server. In this problem, you need to extend the client and server programs in the following way. The client program should first ask the user to enter username and password, and then send them to the server. If the server responds negatively (username and password do not match), the client will close the connection and exit the program. You can decide what message means a negative response from the server. At the server side, the server will first verify the

username and password after a connection is established. If username and password do not match what the server has in the username/password file, the server sends a negative message to the client and closes the connection. Otherwise, the server proceeds to communicate with client further. The username/password file maintained by the server stores the username and the SHA256 (more precisely, the sha256_base64) digest of the real user password. When a server receives a pair of username and password, it will first convert the received password into its sha256_base64 digest, and then compare with the stored password digest of the corresponding username to determine if they match. Make sure you are familiar with the user_password.pl and load_user_password.pl programs. On the server machine, you should run user_password.pl to create the password file that can be used by the server program. You can use load_user_password.pl as a starting point for the server to maintain the username and password information. If the username and password verification is successful at the server side, the client program should continue read the user input line by line, until the user types quit, or end-of-file is encountered, or the program is killed. Instead of arbitrary strings, what a user types will be Unix command-line commands, for example, ls, who, and ps. In our test, we will only test simple commands like these, which will produce all outputs and then terminates. In particular, we will not test programs such as top, which will continue run. At the server side, (after the username/password verification step), instead of simply echoing back the received string, it should treat it as a Unix command-line command, and run it. The output of the command will be sent back to the client. The server should be implemented as a concurrent server; that is, upon each connection being accepted, a child process will be created to interact with the client (verify username and password, read command from client, run the command, and send back the result, and so on) with the accepted socket. The parent process should continue to accept new connection requests using the listen socket. Note that, as a common practice, you should close the accepted socket in the parent process, and close the listen socket in the child process, before proceeding to perform other tasks. The server program will take two command-line arguments, the server port number, and the username/password file (which stores the username and sha256_base64 digest of the corresponding password). Each line of the username/password file contains the username and the sha256_base64 digest of the corresponding password, separately by a whitespace. The client program will take two command-line arguments, the server IP address or hostname, and the port number of the server. An example run of the program is given below. duan@linprog7 (~...assignment/solutions) % perl con_server2.pl 5678 user_password_file.txt One connection is established. One connection has been disconnected.

// the server continue run duan@linprog7 (~...assignment/solutions) % perl con_client2.pl linprog7 5678 linprog7 5678 Username: test1 Password: password is OK. MSG TO SERVER: ps MSG FROM SERVER: PID TTY TIME CMD 28224 pts/23 00:00:00 perl 28229 pts/23 00:00:00 perl 28322 pts/23 00:00:00 ps 57163 pts/23 00:00:00 reg-tcsh MSG TO CLIENT: quit

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

A Survey Of Financial And Managerial Accounting

Authors: Roger H. Hermanson, Roland F. Salmonson, James D. Edwards

5th Edition

025606976X, 978-0256069761

More Books

Students also viewed these Accounting questions

Question

1. Define mass and mediated communication

Answered: 1 week ago