From bash you can (save to ~/.bashrc or something else):
function create-follower () { local _NAME=$1; local _USER=$2; local _HOST=$3; local _PATH=$4; if ! [ "${_NAME}" ]\ || ! [ "${_USER}" ]\ || ! [ "${_HOST}" ]\ || ! [ "${_PATH}" ] ; then { echo "Cannot create log follower." ; echo; echo "Usage: create-follower NAME USER HOST LOG-FILE"; } >&2; return 1 ; fi ; eval "function ${_NAME}(){ ssh ${_USER}@${_HOST} tail -f \"${_PATH}\" & }" } function activate-followers () { if (( $# < 1 )) ; then { echo "You must specify at least one follower to use" ; echo ; echo "Usage:" ; echo " activate-followers follower1 [follower2 ... followerN]"; } >&2; return 1 ; fi ; for FOLLOW in "${@}" ; do ${FOLLOW} ; done ; wait; } function stop-followers () { if [ "$(jobs)" ] ; then kill -9 $(jobs | perl -pe 's/\[([0-9]+)\].*/%$1/') ; fi ; }
And then from your shell, determine the logs you want to use:
[ dsm@localhost :~]$ create-follower test1 user1 localhost /tmp/log-1.txt [ dsm@localhost :~]$ create-follower test2 user2 otherhost /tmp/log-2.txt [ dsm@localhost :~]$ create-follower test2 user3 remotebox /tmp/log-3.txt
Now activate the followers:
[ dsm@localhost :~]$ activate-followers test1 test2 test3
To exit a function, use CTRL+C , and to stop background processes use:
[ dsm@localhost :~]$ stop-followers
NOTE 1: This assumes that public key authentication has been set for your mailboxes.
NOTE 2. You will need to kill all tasks remaining after exiting the activation-repeater function. You might want to do this manually, as the provided function removes brute force in all background jobs
NOTE 3. This assumes a unix-like working environment that you can get by installing cygwin.
Who says you cannot do lisp in shellscript; -)
source share