linux - How do I get a sound to fire on local machine when I run a bash script on a remote computer via SSH? -


i have script makes beep when memory used. deploy script remote computer , run through ssh. unfortunately, makes remote computer beep , not mine. there way around this?

#!/bin/bash # peter black # alarm.sh max_percent=94 sleeper=1 frequency=1000 duration=300  # enable script: # chmod u+x alert.sh  # total available memory: function total_memory {     echo "total memory available: "     total_mem=$(grep memtotal /proc/meminfo | awk '{print $2}')     #another way of doing that:     #total_mem=$(awk '/memtotal/ {print $2}' /proc/meminfo)     echo "---------- $total_mem ---------------" }   # alarm function params: frequency, duration # example: # _alarm 400 200 _alarm() {   ( \speaker-test --frequency $1 --test sine )&   pid=$!   \sleep 0.${2}s   \kill -9 $pid }  function total_available_memory {     total_available_mem=$(</proc/meminfo grep memtotal | grep -eo '[0-9]+')     total_free_mem=$(</proc/meminfo grep memfree | grep -eo '[0-9]+')     total_used_mem=$((total_available_mem - total_free_mem))     #percent_used=$((total_available_mem / total_free_mem))     # print free memory     # customize unit based on format of /proc/meminfo     percent_used=$(printf '%i %i' $total_used_mem $total_available_mem | awk '{ pc=100*$1/$2; i=int(pc); print (pc-i<0.5)?i:i+1 }')      if [ $percent_used -gt $max_percent ];         echo "too memory beign used!!!!!!!! kill it!"         _alarm $frequency $duration     fi      echo "available: $total_available_mem kb  -  used: $total_used_mem kb  -  free: $total_free_mem kb  -  percent used: $percent_used %"  }  # run functions in infinite loop: # total_memory  echo "press [ctrl+c] stop.." while :     total_available_memory     sleep $sleeper done 

well, there simple way:

ls -l >/dev/dsp 

:-)

it channel directory text sound output if wav file. doesn't sound :-) alarming wonderful. requires have kernel module producing /dev/dsp device.


alternatively, can beep on character terminal of console, need redirect beep output that:

echo -en "\007" >/dev/tty1 

will want. requires turned on speaker , active console desktop (it x server runs, maybe won't work).


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -