Question

I need to create a shell script that will remind the employees to fill n their...

I need to create a shell script that will remind the employees to fill n their timecards at the end of each day using variables to define the names of all the employees - I could really use some help!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The shell script to remind the employees to fill their timecards at the end of the day is shown below and executed:

CODE:

Input file employees.dat containing employee name. For any new employee we can add employee name here.

Unix Terminal> cat employees.dat

Ravi Kishan

Roshan Kumar

Robert Lafore

Henry Herbert

Dennis Raid

Unix Terminal>

Code:

Unix Terminal> cat remind_emp.sh

#!/bin/bash

# timesheet file to log the logout time of an employee

timesheet='/tmp/emp_timesheet.dat'

# input file employees.dat containing employee names

emp='employees.dat'

# if /tmp/emp_timesheet.dat file already exist zero the contents of file

test -e $timesheet && cat /dev/null > $timesheet

IFS=$'\n'

# iterating through each employee in employees file

for each_emp in `cat $emp`

do

# getting employee log out time

echo "Enter the log out time of ${each_emp}: "

read log_time

# writing employee name and log out time to the timesheet file

echo "$each_emp $log_time">>$timesheet

done

echo "Log out time of all the employees recorded..."

Unix Terminal>

OUTPUT:

Unix Terminal> bash remind_emp.sh Enter the log out time of Ravi Kishan: 5pm Enter the log out time of Roshan Kuman: 6pm Ente

Add a comment
Know the answer?
Add Answer to:
I need to create a shell script that will remind the employees to fill n their...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need help with this. 1. In a bash shell script, what are the required elements...

    I need help with this. 1. In a bash shell script, what are the required elements of an "if" control structure? 2. In a bash shell script, what are the optional elements of an "if" control structure? 3. In a bash shell script, what are the required elements of a "while" control structure? 4. What is the difference between a shell variable and environment variable? Which one is considered local and which is considered global? 5. List the four kinds...

  • Hello, I am attempting to write a basic shell script using bash. It will need to...

    Hello, I am attempting to write a basic shell script using bash. It will need to print the user, host, time, and date. It will need to take user input for a txt file to be searched and create a new file to save the results. It must print the number of lines and characters in the text. The user will need to enter three words to be searched, and the number of occurrences of those words in the text...

  • You will create a shell script that prints out the following information about the system it is run on: • The system’s n...

    You will create a shell script that prints out the following information about the system it is run on: • The system’s name and IP address • How much memory the system is currently using, and how much total memory it has • The number of CPUs of the machine • The number of unique users on the system at that moment When your script is run, each of these values should be clearly labeled in the output, such as...

  • You will create a shell script that prints out the following information about the system it...

    You will create a shell script that prints out the following information about the system it is run on: • The system’s name and IP address • How much memory the system is currently using, and how much total memory it has • The number of CPUs of the machine • The number of unique users on the system at that moment When your script is run, each of these values should be clearly labeled in the output, such as...

  • Hi, I need help for solving Linux question. . 1.Using the proper text editor, create a...

    Hi, I need help for solving Linux question. . 1.Using the proper text editor, create a shell file called by (your name), your enrollment number, your program and the courses you study. Use the appropriate variables and display the above to the standard output (screen). . 2. Write A Shell Script to perform the following: Display the files and directories Print the date in 24 hour format Display the System id Display the current working directory Print the status of...

  • Part 1: Create a shell script that returns a full name associated with a userid specified...

    Part 1: Create a shell script that returns a full name associated with a userid specified in the command line argument. • Use the names found in /acct/common/CSCE215-Spring19. • Your shell script should be named “findName.sh” – Example usage: $ ./findName.sh seiei SETSUNA F SEIEI $ – Your shell script must either: Return the full name associated with the userid or Return an error message if the command line arguments are not equal to 1. or Return the message “Sorry...

  • I am a college student taking an INTRODUCTORY linux shell programming course and need some help...

    I am a college student taking an INTRODUCTORY linux shell programming course and need some help with writing a for statement. How would I write a for statement to process all the arguments at the command line and indicate if the argument contains the name of a student in my class. The names of the students are in the file cis132students.   I realize you do not have the file but if you could write it I could see if it...

  • I need help to (let <arithmetic expression>) (expr item1 operator item2) $(( expression )) (${#variable}) Create...

    I need help to (let <arithmetic expression>) (expr item1 operator item2) $(( expression )) (${#variable}) Create a simple script which will take two command line arguments and then multiply them together using each of the methods detailed above. These are the methods detailed above Write a Bash script which will print tomorrows date. (Hint: use the command date) Remember when we looked at variables we discovered $RANDOM will return a random number. This number is between 0 and 32767 which...

  • Hello I need help creating a bash script in linux for the following question: Create a...

    Hello I need help creating a bash script in linux for the following question: Create a script to expand the jpeg creator to create other types of files such as pdf, png, gif, etc. The jpeg creator is the following: #!/bin/bash FILE=$1 echo -e -n "\xFF\xD8\xFF\xE0"> $FILE dd if=/dev/random bs=512 count=4 >> $FILE

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