title: Bash Script for Cisco devices
body: <p>i trying to do a bash script that connects to Cisco Switches and print the output in a file created with name --> TimestampDeviceXX_Check.txt
  and after compare the outputs to see if there are differences in the output files. (they must be the same because their config must be aligned).</p>
  
  <p>I've already the scripts  for connect to the switches so  i only have to lauch the xxx.sh to log in the device.</p>
  
  <p>here is the idea that i want to create and i ll appreciate if you help me:</p>
  
  <p>I'm new to bash scripting  and certanly i know that i did some errors.... i hope that you ll help me </p>
  
  <p>Thanks, Regards T. :)</p>
  
  <pre><code>#!/bin/bash
  
  devices="
  ./Shop1/Sw1-ab2.sh  
  ./Shop2/Sw1-cd1.sh  
  ./Shop3/Sw1-ef1.sh  
  "
  
  
  outdir=$(./Check/$(date +%Y%m%d)/Check_$(date +%Y%m%d%H%M%S).dir)
  
  for device in $devices; do
  
          logfile=${outdir}/$(basename ${device} .sh).txt
          if[! -e $logfile] ; then
                  touch $logfile
          fi
          expect &lt;&lt;- END &gt; ${logfile}
                  spawn "${device}"
                  expect "#"
                  send "terminal length 0\r"
                  expect "*#"
                  send "show running-config | begin mac access-list extended \n"
                  expect "#"
                  send "show mac address-table vlan xx\n"
                  expect "#"
                  send "show mac address-table vlan xx\n"
                  expect "#"
                  send "exit\r"
                  expect closed
  
          END
  
          echo ${device}
          echo "==================================="
          echo
  &gt;done
  </code></pre>