summaryrefslogtreecommitdiff
path: root/bin/greet
blob: 50f6dce10267684ae1cdd57555816a0de70edf63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/sh

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
  echo "I could not find '${USER}'"
  exit 1
fi