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...

  • 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...

  • 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

  • I need help with this python programming exercise, please! thanks in advance Create a Python script...

    I need help with this python programming exercise, please! thanks in advance Create a Python script file called hw4.py. Add your name at the top as a comment, along with the class name and date. Both exercises should be in this file, with a comment before each of them to mark it. Ex. 1. Write a program that inputs an integer number from the user, then prints a letter "O" in ASCII art using a width of 5 and the...

  • Unix questions, i need help on Hint: Commands to study to answer this question: predefined shell...

    Unix questions, i need help on Hint: Commands to study to answer this question: predefined shell variables, and .profile script file, echo SHELL, HOME, PATH, MAIL and TERM are predefined shell variables. You can use the value of a shell variable in a shell command putting $ in front of it. For example, to display the value of the HOME directory of the user, specify $HOME in the echo command like echo $HOME. Do not give just the value of...

  • I could really use some help explaining this -You should be able to fill in all...

    I could really use some help explaining this -You should be able to fill in all hypothalamus/pituitary/endocrine organ axes

  • I need this done ASAP. Please write a bash shell script that does the following: Prints...

    I need this done ASAP. Please write a bash shell script that does the following: Prints out how many users are logged on. This can be accomplished using who and wc. Prints out a list of currently logged on users. This can be accomplished using who, grep, regular expressions, and echo. Prints out how many processes you have running from past days, and a list of those jobs. Use `whoami` to get your username. Run ps -ef and see how...

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
ADVERTISEMENT