title: command not found and not a valid identifier
body: <p>EDIT: After posting it looks like example input I included didn't get formatted properly in the post. I added extra new lines in the block quotes to make it easier to read.</p>
  <p>So this is a two part, and I'm sorry if I'm duplicating anywhere. I read what looked like the relevant topics to the two errors I got.</p>
  <p>I wrote a script that interfaces with the API of a wireless controller, and I handed that off to a customer. I tested the script on two different flavors of Linux (albeit both Debian), both of which worked. Here's the script in it's entirety.</p>
  <pre><code>#!/bin/bash
  
  LOG=~/mac_add.log
  cOpt=&quot;-i -H Accept:application/xml -H Content-Type:application/xml -X POST -k -u&quot;
  
  read -p &quot;Enter IP: &quot; ipAddr
  if [[ $ipAddr =~ ^([0-9]{1,3}.){3}[0-9]{1,3}$ ]]; then {
    echo &quot;IP address $ipAddr... OKAY&quot;
  } else {
    echo &quot;Invalid IP address&quot;
    exit
  } fi
  
  read -p &quot;Enter username: &quot; user
  if [[ $user =~ ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$ ]]; then {
    echo &quot;User $user... OKAY&quot;
  } else {
    echo &quot;Invalid email address&quot;
    exit
  } fi
  
  read -sp &quot;Enter password: &quot; passwd
  echo &quot;&quot;
  read -p &quot;Enter name of domain: &quot; domain
  domain=&quot;${domain// /%20}&quot;
  read -p &quot;Role ID: &quot; role
  read -p &quot;Enter file with MAC addresses: &quot; inFile
  
  if [ ! -f $inFile ]; then {
    echo &quot;$inFile not found&quot;
    exit
  } fi
  
  cat $inFile | while read line; do {
    name=&quot;$(echo $line|sed 's/\(.*\),.*/\1/')&quot;
    mac=&quot;$(echo $line|sed 's/.*,//')&quot;
    if [[ $name =~ ^[a-zA-Z]{1}[a-zA-Z0-9\ ]+$ ]]; then {
      if [[ $mac =~ ^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$ ]]; then {
        curl $cOpt $user:$passwd https://$ipAddr:3000/macdevices?active_domain_name=office -d &quot;&lt;macdevice&gt;&lt;name&gt;$name&lt;/name&gt;&lt;role_id&gt;$role&lt;/role_id&gt;&lt;address&gt;$mac&lt;/address&gt;&lt;/macdevice&gt;&quot;
      } else {
        echo &quot;The MAC address $mac is invalid&quot; &gt;&gt; $LOG
      } fi
    } else {
      echo &quot;The name $name is invalid&quot; &gt;&gt; $LOG
    } fi
  } done
  </code></pre>
  <p>The input file is a CSV file. Each line is should be of the format &quot;name,MAC&quot;. Below are the contents of the file I used for testing.</p>
  <blockquote>
  <p>name4,00:19:92:ab:cd:3f</p>
  <p>name3,ag:10:12:31:32:32</p>
  <p>name2,3214:1f:ed:ab:22</p>
  <p>name1,AB:CD:EF:12:33:44</p>
  <p>5name,AB:CD:EF:12:33:44</p>
  <p>paul smith,AB:CD:EF:12:33:44</p>
  </blockquote>
  <p>I handed this to the customer, and this is what they got.</p>
  <blockquote>
  <p>$ bash mac-add.bsh</p>
  <p>: command not found:</p>
  <p>: command not found:</p>
  <p>Enter IP: redacted</p>
  <p>': not a valid identifier: `ipAddr</p>
  <p>mac-add.bsh: line 7: syntax error in conditional expression: unexpected token `('</p>
  <p>mac-add.bsh: line 7: syntax error near `^(['</p>
  <p>'ac-add.bsh: line 7: `if [[ $ipAddr =~ ^([0-9]{1,3}.){3}[0-9]{1,3}$ ]]; then {</p>
  <p>Last return status: 2</p>
  </blockquote>
  <p>So I thought maybe they don't have the version of bash that supports regex. They say they're running 4.1.3 which I believe should. I'm not entirely sure what flavor Linux, but really I just want to know what's wrong with this so I can work on portability. I'm also open to using a different language if needed.</p>
  <p>My initial thoughts are to simplify the script by removing LOG and cOpt, the latter because I just used it to make the cURL call one line. I would also remove the regex checks.</p>