An XMPP/Jabber echo bot written in sed
&quot;All you have is openssl, bash, dig, stdbuf and sed?&quot;<p>s&#x2F;sed&#x2F;GNU sed&#x2F;<p>echoz.sh also uses cut, base64, stdbuf, tr, mkfifo, tee and sort.<p>echoz.sh does not seem to have any &quot;bashisms&quot; 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&#x2F;dev&#x2F;stdout 
</code></pre>
The uses of cut to isolate substrings and tr to replace characters can also be acomplished using sed.<p><pre><code>   #!&#x2F;bin&#x2F;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 &#x27;   #include &lt;stdio.h&gt;
   int main(){
   setvbuf(stdin,NULL,_IONBF,0);
   setvbuf(stdout,NULL,_IONBF,0);
   char *b[&#x27;$((a+1))&#x27;];&#x27;
   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 &#x27;
   b[&#x27;$n&#x27;]=&quot;&#x27;$1&#x27;&quot;;&#x27;
   shift 1;
   n=$((n+1));   
   done;
   echo &#x27;   b[&#x27;$n&#x27;]=(void *)0;
   execve(&quot;&#x27;$b&#x27;&quot;,b,(void *)0);
   }&#x27;; 
   }|exec cc -xc - -static &amp;&amp; exec a.out</code></pre>