Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, Please edit my Linux BASH script so it runs successfully. DIRECTIONS: Name Your Script mailProcessing Have your script check the mail spool for any

Hello,

Please edit my Linux BASH script so it runs successfully.

DIRECTIONS:

Name Your Script mailProcessing Have your script check the mail spool for any new messages If a message is found: Create a new file Call This File _.mesg Replace with sender's email, Replace date with time message was sent Once file is created, you will need to auto-reply to the message sender with the following: Message saying that their message was received successfully

MY SCRIPT:

#! /bin/bash

# The first token read should be "From" indicating a new message. # We will start a loop that will continue as long as there is a message while read label contents ; do while [ $? -eq 0 -a "$label" == "From" ]; do # Process The Header # Run this loop until we hit a blank line while [ "$label $contents" != " " ]; do # Process the header information using a case statement case "$label" in "From") # Extract userName/sender and Time Stamp from contents email=${contents%% *} sender=${email%@*} timestamp= # example: How to remove blank spaces from a string # var= " lakdjsf lkadsjf "; var=$(echo "$var" | sed 's/[[:space:]]//g') # result will be: lakdjsflkadsjf timpestamp= ;; * ) : # A : is a placeholder so the script continues. ;; esac # Read the next line of the message read label contents done

# At this point, I should be at a blank line. # Let's read the next line to read the beginning of the message body touch _.mesg read label contents # Process The Body # Loop until blank line which indicates end of message while [ "$label $contents" != " " ]; do # ADD Code Here To Append Message Body To .mesg file # HINT: Look at how we echo information in the case statement. # Its the exact same code without the case statement syntax. echo $label $contents >> .mesg # Read next line of the message read label contents done # We have hit the end of the message. We will now close off the loop. If # another message exists, this process will start over. done # Reply to the sender done < /var/mail/$USER

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_2

Step: 3

blur-text-image_3

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

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

More Books

Students also viewed these Databases questions

Question

Azure Analytics is a suite made up of which three tools?

Answered: 1 week ago