TechExhibeo

ssh message

Mar 12th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. SendMessage()
  4. {
  5. com=`tty`
  6. set `who am i`
  7. who | grep -v "$1" >filef.txt
  8.  
  9. exec < filef.txt
  10. array=""
  11.  
  12. while read line
  13. do
  14. set $line
  15. echo $1
  16. array+=($1)
  17. done
  18.  
  19. rm filef.txt
  20. exec <$com
  21.  
  22. echo "====================> Select User Number <===================="
  23. echo
  24.  
  25. select userName in ${array[@]}
  26. do
  27. UserNam=$userName
  28. if [ -n $UserNam ]; then
  29. break
  30. fi
  31. done
  32.  
  33. unset array #Clear the Array
  34.  
  35. echo
  36. echo
  37.  
  38. echo "===================================> Message Body <==================================="
  39.  
  40. mesg y
  41. read -p "put here your Message==> " messagel
  42.  
  43. echo $messagel | write $UserNam
  44.  
  45. if [ $? -eq 0 ]; then
  46. echo "It has been sent successfully.............ok"
  47. #return 0
  48. else
  49. echo "Message Failed to send ..............No!!"
  50. echo "Maybe It is not available for you To send Message To hem "
  51. return 1
  52. fi
  53. }
  54.  
  55. SendMessage
Add Comment
Please, Sign In to add comment