Skip to content

Instantly share code, notes, and snippets.

@mtorrisi
Created November 16, 2016 14:17
Show Gist options
  • Save mtorrisi/254d482cc64b4a36175fd39aa775a2fc to your computer and use it in GitHub Desktop.
Save mtorrisi/254d482cc64b4a36175fd39aa775a2fc to your computer and use it in GitHub Desktop.
Demo sayhello script
#!/bin/bash
INPFILE=sayhello.txt
DATAFILE=sayhello.data
DELAY=2
printf "starting at: " ; date
printf "running on: "; $(hostname -f)
printf "whoami: "; whoami
printf "home: "; echo $HOME
printf "listing home:\n"
ls -l $HOME
printf "working directory: "; pwd
printf "listing working directory:\n"
ls -l $PWD
if [ "${@}" = "" ]; then
SAYS="nothing"
else
SAYS="$@"
fi
echo "User "$(whoami)" says: $SAYS" | tee -i $DATAFILE
if [ -f "$INPFILE" ]; then
echo "Receiving sayhello.txt file"
cat $INPFILE
else
echo "Did not find $INPFILE"
fi
printf "waiting for a while ($DELAY minutes) ... "
sleep $((60*DELAY)) # Wait few minutes
echo "done"
printf "ending at: "; date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment