The question makes very little sense but lets get into it! I am working on a IRC Client in bash and I found some code and started adding it to an IRC bash bot code I have been working on. I have broken it down to simplify it. GNU bash, version 4.3.48(1)-release
#!/bin/bash
#!/user/bin/perl
function status_line() {
echo -en '\e7' "\e[${status_line_row};0f" '\e[2K'
echo -en "\e[4;44mSTATUS: $nick in $channel @ $channel\e[0m"
echo -en '\e8'
}
function read_line() {
while true
do
while read -r -t1
do
status_line
echo -en '\e[2K\r> '
echo "PRIVMSG $channel :$REPLY" >> $input
done
done
}
. bot.properties
input=".bot.cfg"
echo "Starting session: $(date "+[%y:%m:%d %T]")">$log
echo "NICK $nick" > $input
echo "USER $user" >> $input
echo "JOIN $channel" >> $input
read_line | tail -f $input | openssl s_client -connect $server:6697
Upon running this and typing input into terminal it does correctly input and send $REPLY to IRC but it does not correctly do status_line and echo -en '\e[2K\r> ' inside read_line. I am confused why the input is being read but the 2 lines before it aren't working. I ran bash -x on it to see this (below) after sending a msg to IRC and this doesn't even fix it without -x.
+ status_line
+ echo -en '\e7' '\e[;0f' '\e[2K'
+ echo -en '\e[4;44mSTATUS: Omen in #lair @ #lair\e[0m'
+ echo -en '\e8'
+ echo -en '\e[2K\r> '
+ read -r -t1
+ true
If you wish to see the full code it is here > https://pastebin.com/cHLiwZNf
tail -f
, right?tail -f
. :/read_line
writes to$input
. You will have to make everything write directly toopenssl
. The issue is with buffering. I think Linux has some sort ofsetbuf
command that may help (to turn off buffering), but I'm currently unable to test.expect
instead ofbash
. Or, better yet, a language like perl or python which have expect-like libraries AND libraries with binding to openssl C library functions.stdbuf