Artificial intelligent assistant

Ugly bash function to send commands and "say" anything in screen over ssh. Is there a better way? I’m working on a function this works but it is ugly. One thing that could be changed is being able to know the name of the screen. Using screen -dms minecraft java ….jar now starts a screen session named with what appears to be random numbers..hostname. Next is the voodoo that happens to strip the name from screen -ls and use it. Then there is awk. There has to be a better way. say_this() { REEN="$(ssh -p 8989 192.168.1.101 screen -ls)" echo $REEN > log/log.txt AWK="$(awk 'FNR == 1 { print $6 }' log/log.txt)" NAME="$(echo $AWK)" echo $1 ssh -p 8989 192.168.1.101 screen -S $NAME -p 0 -X stuff \"$1^M\" } say_this "say test" say_this "say !@#$%^&*()<>?This string should work!"

You're using a lot of variables and a log file unnecessarily.

I'm not sure about the stuff after `stuff`, but I bet it can be simpler:


say_this()
{
local name="$(ssh -p 8989 192.168.1.101 screen -ls | awk 'NR==2 {print $1}')"
echo "$1"
ssh -p 8989 192.168.1.101 screen -S "$name" -p 0 -X stuff "$1"
}

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy a069fd013308bcf5353a49700ebfb71b