title: Bash Script Command Not Executing
body: <p>I need help with the following Bash v4.1.2 script.</p>
  
  <pre><code>#!/bin/bash
  
  IP=$1
  IPTABLES=/sbin/iptables
  $IPTABLES -I INPUT -s $IP -j DROP
  echo $IPTABLES -I INPUT -s $IP -j DROP |wall
  </code></pre>
  
  <p>The variables, <code>IP</code> and <code>IPTABLES</code>, get populated in the <code>echo</code> but the line above is not executed.  The echo outputs...</p>
  
  <p><code>/sbin/iptables -I INPUT -s 1.2.3.4 -j DROP</code></p>
  
  <p>...which is syntactically correct and works if executed manually.</p>
  
  <p>I don't know Bash so I'm struggling to debug this elementary script.  I see some scenarios where commands are left bare as I have mine and some that are wrapped in <code>$()</code> (with and without quotes).  I've also tried using backticks and quoting various parts of the command.  The <code>echo</code> piped through <code>wall</code> only exists for debugging.</p>
  
  <p>I found a basically identical post at <a href="https://stackoverflow.com/questions/22984318/bash-script-commands-not-working-in-cron">Bash script commands not working in cron</a>.  My script is not running from cron though.</p>
  
  <p>=== EDIT ===<br>
  Added for @Barmar</p>
  
  <pre><code>[root@server tmp]# bash -x /bin/netfilter-drop.sh 
  + IP=1.2.3.4
  + IPTABLES=/sbin/iptables
  + /sbin/iptables -I INPUT -s 1.2.3.4 -j DROP
  + wall
  + echo /sbin/iptables -I INPUT -s 1.2.3.4 -j DROP
  [root@server tmp]# 
  Broadcast message from root@server (Thu Dec 29 12:46:44 2016):
  
  /sbin/iptables -I INPUT -s 1.2.3.4 -j DROP
  ^C
  [root@server tmp]#
  </code></pre>