summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--EXAM.md6
-rwxr-xr-xbin/greet6
2 files changed, 12 insertions, 0 deletions
diff --git a/EXAM.md b/EXAM.md
index f02f49a..bd7af87 100644
--- a/EXAM.md
+++ b/EXAM.md
@@ -139,6 +139,12 @@ Some examples of IPC mechanisms are:
cd "$(dirname "$0")/.."
USER=${1}
+# broadcast
+for i in `grep $USER /etc/passwd | cut -d: -f1`; do
+ (echo 'hello' | write "$i") || true
+done
+
+# or find a specific user
if cat /etc/passwd | cut -d: -f1 | grep -E "^$USER"; then
echo "hello" | write "$USER"
else
diff --git a/bin/greet b/bin/greet
index 947958e..50f6dce 100755
--- a/bin/greet
+++ b/bin/greet
@@ -3,6 +3,12 @@
cd "$(dirname "$0")/.."
USER=${1}
+# broadcast
+for i in `grep $USER /etc/passwd | cut -d: -f1`; do
+ (echo 'hello' | write "$i") || true
+done
+
+# or find a specific user
if cat /etc/passwd | cut -d: -f1 | grep -E "^$USER"; then
echo "hello" | write "$USER"
else