An XMPP/Jabber echo bot written in sed
"All you have is openssl, bash, dig, stdbuf and sed?"<p>s/sed/GNU sed/<p>echoz.sh also uses cut, base64, stdbuf, tr, mkfifo, tee and sort.<p>echoz.sh does not seem to have any "bashisms" so perhaps one does not actually need bash and other sh will suffice.<p>stdbuf is absent from some BSD UNIX.  Below is a small script to try to unbuffer output from any program without using LD_PRELOAD. base64 is also absent from some BSD UNIX and can be replaced with<p><pre><code>   openssl enc -a
</code></pre>
tee can be replaced with<p><pre><code>   sed -u w/dev/stdout 
</code></pre>
The uses of cut to isolate substrings and tr to replace characters can also be acomplished using sed.<p><pre><code>   #!/bin/sh
 
   test $# -ge 1||exec echo usage: $0 program arguments ;
   maxarg=5;
   test $# -le $maxarg||exec echo max $maxarg arguments ;
   {  
   a=$#;
   b=$(command -v $1);
   echo -n '   #include <stdio.h>
   int main(){
   setvbuf(stdin,NULL,_IONBF,0);
   setvbuf(stdout,NULL,_IONBF,0);
   char *b['$((a+1))'];'
   n=0;while true;do
   test $n -le $maxarg||exit;
   a=$((a-1));
   test $a -ge 0||if export n;then echo;break;fi ;
   echo -n '
   b['$n']="'$1'";'
   shift 1;
   n=$((n+1));   
   done;
   echo '   b['$n']=(void *)0;
   execve("'$b'",b,(void *)0);
   }'; 
   }|exec cc -xc - -static && exec a.out</code></pre>