[problem]
As most UNIX bods know, with fairly recent audit lock downs – talkd has been disabled.
But you want to chat remotely with someone, i.e. another techie bod! 🙂
[/problem]
[solution]
Now where is the fun in that! 🙂
Don’t know about you, but quite often I’ve needed to talk to other people remotely and don’t want to hold a phone or use hands free.
See the example.
[/solution]
[example]
Here is a quick and dirty solution, that works with bash – should work with zsh too.
I welcome any enhancements or suggestions, via the comments.
#!/bin/bash
trap 'kill $tailpid;echo "*$nick leaves chat*" >> ${chatdir}/discussion;
rm ${chatdir}/.${nick};exit 0' 2
chatdir="/var/tmp/unixchat"
[ -d $chatdir ] || {
mkdir $chatdir || (echo "failed to mkdir $chatdir";exit 1)
}
chmod 777 /var/tmp/unixchat
while [ $(echo X${nick} | grep -c "^X$") -eq 1 ]
do
echo -n "Nick: "
read nick
[ -f "${chatdir}/.${nick}" ] && {
echo "$nick already exists, try another";nick=""
}
done
touch ${chatdir}/.${nick}
[ ! -f ${chatdir}/discussion ] && {
touch ${chatdir}/discussion
chmod 666 ${chatdir}/discussion
}
echo "*$nick joins chat*" >> ${chatdir}/discussion
tail -1000f ${chatdir}/discussion&
tailpid=$!
echo ">> type quit to exit <<"
while [ $(echo X${entry} | grep -c "^Xquit$") -ne 1 ]
do
read entry
echo "[${nick}@`date '+%d-%b %H:%M:%S'`] says: $entry" >> ${chatdir}/discussion&
done
kill $tailpid; rm ${chatdir}/.${nick}
echo "*$nick leaves chat*" >> ${chatdir}/discussion
exit 0
Here is a screen shot:
[/example]
[reference]
[tags]UNIX, Chat code, Shell Script[/tags]
- Linux Man Pages – kill command
- Linux Man Pages – read command
- Linux Man Pages – rm command
- Linux Man Pages – while command
- Linux Man Pages – tail command
- Linux Man Pages – trap command
- Linux Man Pages – touch command
- Linux Man Pages – mkdir command
- Linux Man Pages – chmod command
[/reference]
If you have found my website useful, please consider buying me a coffee below 😉