Home · Latest · Trends  /  general
-1

shell script for 'watch' functionality

rated 1 times [  0] [ 1]  / comments: 0 / hits: 197  / 4 months ago, fri, mar 17, 2017, 13:45:07
While working with an OpenWRT based router, I noticed that the 'watch' command was missing, and I could not find an OpenWRT installer, so I wrote this quick and dirty version. Enjoy!
#!/bin/sh

COMMAND="$@"
RUN=""
if [ "$COMMAND" == "" ]; then
	echo "No command specified. Exiting."
	exit
fi

while [ "$RUN" == "" ]; do
	DATE=`date`
	RES=`$COMMAND`
	clear
	echo "WATCH: $DATE | Press Any Key To Exit!"
	echo ""
	echo "$RES"
	read -s -n 1 -t 1 RUN
done
More From » general
 

Comments

There are no comments for this Snippet yet
Only authorized users can post. Please sign in first, or register a free account
 
Share
Sponsor
Posted
dj

dj

Member since Mar 17, 2017
Total Code Snippets: 2
Total Comments: 1
Location: n/a
Following
User not following anyone yet.
dj snippets
4 months ago, mon, mar 20, 2017