Lab 6 Standard IO redirection Pipes and tee

Sequence 1: Check System Status and inform Super User (root) about the same.

1. Check the CPU Usage and Memory Utilization

[student @ stationX ~] $ cat /proc/cpuinfo /proc /meminfo

[Student @ stationX ~] $ cat /proc/cpuinfo /proc/meminfo | more

2. Mail the Details to root

[student @ stationX ~] $ cat / proc /cpuinfo /proc /meminfo | mail -s “System Stats for $(hostname)” root@localhost

3. Check the Email account root@localhost

  1. Log in as root

# su –

  1. Run the command mutt or mail .

# mutt

# mail

  1. If you are using mutt Press y.
  2. Select the message you want to View with the up and down Arrows and Press Enter to View it.

Note That while viewing a message, the up and down Arrows Move between  messages , not Lines. To Scroll Within the current message, Use Enter and Backspace

  1. Press q to Exit message View

Sequence 2 : Use Output redirection to grab CPU status

  1. Send the output of date command to a file

[Student @ stationX ~] $ date> cpumem.info

  1. Send CPU info and Memory status to same file. (It should over-write it)

[Student @ stationX ~] $ cat /proc /cpuinfo /proc /meminfo> cpumem.info

  1. Try the same Command again. Send Output of date command to same file to over-write previous contents

[Student @ stationX ~] $ date> cpumem.info

  1. Use >> symbol in place of > to append the file with CPU information and Memory information

[Student @ stationX ~] $ cat /proc/cpuinfo /proc/meminfo >> cpumem.info

  1. Send the contents of this file using piping symbol | as mail to root user

[student @ stationX ~] $ cat cpumem.info | mail -s “System Info for $ (hostname) – 2” root@localhost

 

  1. Use Command Grouping ( ) to send output of multiple commands as mail to root and also display it on the terminal using tee.

[student @ stationX ~] $ (date; cat /proc/cpuinfo /proc/meminfo) | tee cpumem.info | mail -s “System Stats for `hostname` ” root

  1. Try same sequence of commands without command grouping.

[Student @ stationX ~] $ date; cat / proc /cpuinfo / proc /meminfo | tee cpumem.info | mail -s “System Stats for` hostname` ” root

Would Date Print Screen and only to the cat’s output Would be piped to tee.

By |2015-01-01T01:40:58+00:00January 1st, 2015|Linux and Unix, Linux/Unix Basics|0 Comments

About the Author:

Leave A Comment

Show Buttons
Hide Buttons