|
See Appendix A, Exercise Answers for answers. Write a program to parse the output of the date command to get the current day of the week. If the day of the week is a weekday, print get to work , otherwise print go play . Write a program that gets all of the real names of the users from the /etc/passwd file, then transforms the output of the who command, replacing the login name (the first column) with the real name. (Hint: create a hash where the key is the login name and the value is the real name.) Try this both with the who command in backquotes and opened as a pipe. Which was easier? Modify the previous program so that the output automatically goes to the printer. (If you can't access a printer, perhaps you can send yourself mail.) Suppose the mkdir function were broken. Write a subroutine that doesn't use mkdir , but invokes /bin/mkdir with system instead. (Be sure that it works with directories that have a space in the name.) Extend the routine from the previous exercise to employ chmod to set the permissions.
|