bash - How to suppress EOF when echoing messages to wall from a script -


in bash script, use many echo "......." | wall lines broadcast event notifications occur.

however, resulting output on console gets unwieldy:

broadcast message root@bigfoot         (somewhere) @ 16:07 ...  photo backup started on mon oct  7 16:07:55 pht 2013   broadcast message root@bigfoot         (somewhere) @ 16:08 ...  photo backup finished on mon oct  7 16:08:05 pht 2013   broadcast message root@bigfoot         (somewhere) @ 16:08 ...  may unplug photo backup hdd. 

instead, we'd appear more following,

broadcast message root@bigfoot         (somewhere) @ 16:07 ...  photo backup started on mon oct  7 16:07:55 pht 2013 photo backup finished on mon oct  7 16:08:05 pht 2013 may unplug photo backup hdd. 

which kind of appear in open write chat session.

is possible? if so, how should modify script in order achieve desired console output?

each wall invocation add "broadcast message" , blank newline @ top of code.

as result, if want notify users @ timely intevals (e.g. @ start + end of backup) have live banner message.

as @devnull suggested, batch messages. 1 approach declare script wide variable $logmsg , have 2 functions depending on whether want user know or want know now

function log_message {   $logmsg = "$logmsg\n$1" }  function log_message_now {  log_message "$1"  echo "$logmsg" | wall  logmsg = "" } 

(note i've not tested above, may need touch of debugging!)


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -