USING Unix/Linux shell !!!:
1) Write a script (project2.sh) that will take information from a file, and print (user’s choice of printers) identical form letters to each recipient. Either E197, E-199, E-194 printers or to project2.output. Prompt the user for their choice.
2) The script and output file are due: per Moodle timeline. Please upload your fully functioning script (project2.sh) your data file (project2.input) and your output file (project2.output) into Moodle.
3) Requirements of the script.
a. You can use any shell for processing the script (declare on first line).
b. The user of the script will be given print location option.
i. When the user provides print location information print the letters to the identified printer or output file.
c. All output redirection MUST take place in the script.
d. You must use a loop to process each line of the data file if it is processed. Your script should work if there are 4 lines in the data file or 4000 lines in the data file.
e. Your data file must be as shown in item 4. (project2.input)
f. Fully document (comment) all operations within the script.
4) Data file (project2.input) will be as follows:
James,Robert,M,E162K,5101 Evergreen, Dearborn,Mi,48128
Fulton,Brent,M,E162I,5101 Evergreen, Dearborn,Mi,48128
Conner,Marrci,F,P262J,5101 Evergreen, Dearborn,Mi,48128
Conti,Anthony,M,P252F,5101 Evergreen, Dearborn,Mi,48128
5) The contents and example of the of the letter output are as follows:
Dear Mr. James Welcome to Widgets, Inc. Robert. This letter is to inform you of your assigned office space at Widgets, Inc. is in the main Engineering building. Your office is E-1162-K located at 5101 Evergreen, Dearborn Mi. 48121 Sincerely, The Boss
# # # # # # # # # # # # OR # # # # # # # # #
Dear Mrs. Conner Welcome to Widgets, Inc. Marrci. This letter is to inform you of your assigned office space at Widgets, Inc. in the Production building. Your office is P-262-J located at 5101 Evergreen, Dearborn Mi. 48121
Please find the following program to parse the input file
Program:
USER> cat project2.sh
#!/usr/bin/ksh
#using awk to manipulated the input file
awk '
BEGIN {
FS=","
}
{
#update the fields in array
for(i=1; i<=NF;i++)
array[i]=$i;
#print based on Malfe/female
if(array[3] == "M")
printf(" Dear Mr. %s Welcome to widgets, Inc. %s. This
letter is to inform you of your assigned office space at Widgets,
Inc. is in the Main Enginerring building. Your office is %s located
at %s,%s,%s,%s\n", array[1], array[2], array[4], array[5],
array[6],array[7], array[8]);
else
printf(" Dear Mrs. %s Welcome to widgets, Inc. %s.
This letter is to inform you of your assigned office space at
Widgets, Inc. is in the Main Enginerring building. Your office is
%s located at %s,%s,%s,%s\n", array[1], array[2], array[4],
array[5], array[6],array[7], array[8]);
}
' <project2.input >project2.output
Output:
USER>cat project2.output
Dear Mr. James Welcome to widgets, Inc. Robert. This letter is to
inform you of your assigned office space at Widgets, Inc. is in the
Main Enginerring building. Your office is E162K located at 5101
Evergreen, Dearborn,Mi,48128
Dear Mr. Fulton Welcome to widgets, Inc. Brent. This letter is to
inform you of your assigned office space at Widgets, Inc. is in the
Main Enginerring building. Your office is E162I located at 5101
Evergreen, Dearborn,Mi,48128
Dear Mrs. Conner Welcome to widgets, Inc. Marrci. This letter is to
inform you of your assigned office space at Widgets, Inc. is in the
Main Enginerring building. Your office is P262J located at 5101
Evergreen, Dearborn,Mi,48128
Dear Mr. Conti Welcome to widgets, Inc. Anthony. This letter is to
inform you of your assigned office space at Widgets, Inc. is in the
Main Enginerring building. Your office is P252F located at 5101
Evergreen, Dearborn,Mi,48128
USING Unix/Linux shell !!!: 1) Write a script (project2.sh) that will take information from a file,...