Add a couple of questions
This commit is contained in:
20
exercises/shell/solutions/host_status.md
Normal file
20
exercises/shell/solutions/host_status.md
Normal file
@@ -0,0 +1,20 @@
|
||||
## It's Alive!
|
||||
|
||||
### Objectives
|
||||
|
||||
1. Write a script to determine whether a given host is down or up
|
||||
|
||||
### Solution
|
||||
|
||||
```
|
||||
#!/usr/bin/env bash
|
||||
SERVERIP=<IP Address>
|
||||
NOTIFYEMAIL=test@example.com
|
||||
|
||||
ping -c 3 $SERVERIP > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
# Use mailer here:
|
||||
mailx -s "Server $SERVERIP is down" -t "$NOTIFYEMAIL" < /dev/null
|
||||
fi
|
||||
```
|
Reference in New Issue
Block a user