stdinclient-vitali64.sh 608 B

12345678910111213141516171819202122232425
  1. #!/bin/sh
  2. if [ -z "$5" ]
  3. then
  4. printf '%s: Five arguments are required: Hostname, port, username, password and channel.\n' "$0" > /dev/stderr
  5. exit 1
  6. fi
  7. rm cow
  8. printf 'LOGIN\tUSERNAME=%s\tPASSWORD=%s\r\n' "$3" "$4" > cow
  9. tail -n 1 -f cow | nc "$1" "$2" | sed -e "s/CHANMSG\tSOURCE=/"$(date '+%H:%M')" </g" -e 's/\tMESSAGE=/> /g' -e "s/\tTARGET=$5//g" -e 's/\tTYPE=NORMAL//g' &
  10. ncid="$!"
  11. trap "kill $ncid" EXIT
  12. while read r
  13. do
  14. date=$(date +%H:%M)
  15. printf 'CHANMSG\tTARGET=%s\tMESSAGE=%s\r\n' "$5" "$r" >> cow
  16. done
  17. # this little part doesn't work because sigint isn't caught
  18. kill "$ncid"