4 Replies Latest reply on Dec 11, 2014 7:37 AM by thijn

    using bash commands in Device.CLI.Send Commands fails

    thijn

      Hi

      I am trying to create a script in order to backup a F5 BigIP.

      The scripts runs without issues on the device when i run it on the console(ssh) , but when i use Kiwi Cattools, the script fails.

      The reason i''m using variables, is to be able to backup multiple F5 devices into one dir, retaining the ID of the device.

      I must be doing something dumb, or i don't get it.

       

      #!/bin/bash

      terminal width 120
      FTPHOST=[IP]
      HOST=$HOSTNAME
      USER=F5
      PASS=XXXXX
      UPATH1=Config'/'Current'/'
      UPATH=`date +%Y'/'%m'/'%d`
      FPATH="$UPATH1$UPATH"

       

      cd /config
      tmsh -c "save sys config base"
      cp bigip_base.conf $HOST.conf
      ftp -inv << EOF
      open $FTPHOST
      user $USER $PASS
      bin
      mkdir $FPATH
      put /config/$HOST.conf /$FPATH/$HOST.txt
      close
      bye
      EOF

       

      KiwiCattools fails on reading the variables, i get "waiting for respons to command", waiting for an echo.

      I am using Device.CLI.Send Commands.

      Question ofcourse is... :how to fix it, how to set specifics for each device using variables ? Am i missing the point completly? Is it even possible what i''d like to achieve.

      What am i doing wrong?

       

      If anybody can point me to some docs on how to use bash within scripts for KiwiCatTools, that would be great too.

      Thank you in advance.

      With kind regards, Thijn

        • Re: using bash commands in Device.CLI.Send Commands fails
          bkyle

          Please post Putty log information showing these commands being run.

            • Re: using bash commands in Device.CLI.Send Commands fails
              thijn

              Hi,

              Ofcourse, logfiles.. i'm sorry. i should've added these in the initial post, .

              Well i have two pieces of logs, one is the Kiwicattools info log, the other is session output via a SSH session on the box itself.
              I do appologize.. when i post the logs this forum pushed it into a table layout.. and i dont know how to disable auto table.

              Naturaly i sanitized some of the values.

               

              Info.log.txt

              2014-12-11 10:35:52 4-Debug 0   Kiwi CatTools Service   Marshaller - Running script. Device: hostname.loc
              2014-12-11 10:35:53 4-Debug 1   hostname.locSSH Fingerprint: 8b:7c:0a:21:9d:3d:6d:6b:5f:db:6a:1c:10:a8:88:8d
              2014-12-11 10:35:53 4-Debug 1   hostname.locConnected to 10.0.0.1
              2014-12-11 10:35:53 4-Debug 1   hostname.locLogin F5 Big IP: hostname.loc
              2014-12-11 10:35:53 4-Debug 1   hostname.locWaiting for command prompt
              2014-12-11 10:35:53 4-Debug 1   hostname.locDeviceHostnameID: [username@hostname:Standby:In Sync] ~
              2014-12-11 10:35:53 4-Debug 1   hostname.locLogin to hostname.loc was successful
              2014-12-11 10:35:54 4-Debug 1   hostname.locWaiting for an echo of #!/bin/bash command
              2014-12-11 10:35:54 4-Debug 1   hostname.locWaiting for a response to: #!/bin/bash
              2014-12-11 10:35:54 4-Debug 1   hostname.locWaiting for a response to:
              2014-12-11 10:35:54 4-Debug 1   hostname.locWaiting for an echo of FTPHOST=IPADDRESS command
              2014-12-11 10:35:54 4-Debug 1   hostname.locWaiting for a response to: FTPHOST=IPADDRESS
              2014-12-11 10:35:54 4-Debug 1   hostname.locWaiting for an echo of HOST=$HOSTNAME command
              2014-12-11 10:35:54 4-Debug 1   hostname.locWaiting for a response to: HOST=$HOSTNAME
              2014-12-11 10:35:54 4-Debug 1   hostname.locWaiting for an echo of USER=F5 command
              2014-12-11 10:35:55 4-Debug 1   hostname.locWaiting for a response to: USER=F5
              2014-12-11 10:36:25 2-Warning   1   hostname.locDid not receive expected response to command: USER=F5
              2014-12-11 10:36:25 4-Debug 1   hostname.locWaiting for an echo of PASS=PASS command
              2014-12-11 10:36:25 4-Debug 1   hostname.locWaiting for a response to: PASS=PASS
              2014-12-11 10:36:55 2-Warning   1   hostname.locDid not receive expected response to command: PASS=PASS
              2014-12-11 10:36:55 4-Debug 1   hostname.locWaiting for an echo of UPATH1=Config'/'Current'/' command
              2014-12-11 10:36:55 4-Debug 1   hostname.locWaiting for a response to: UPATH1=Config'/'Current'/'
              2014-12-11 10:37:25 2-Warning   1   hostname.locDid not receive expected response to command: UPATH1=Config'/'Current'/'
              2014-12-11 10:37:25 4-Debug 1   hostname.locWaiting for an echo of UPATH=`date +%Y'/'%m'/'%d` command
              2014-12-11 10:37:25 4-Debug 1   hostname.locWaiting for a response to: UPATH=`date +%Y'/'%m'/'%d`
              2014-12-11 10:37:55 2-Warning   1   hostname.locDid not receive expected response to command: UPATH=`date +%Y'/'%m'/'%d`
              2014-12-11 10:37:55 4-Debug 1   hostname.locWaiting for an echo of FPATH="$UPATH1$UPATH" command
              2014-12-11 10:37:55 4-Debug 1   hostname.locWaiting for a response to: FPATH="$UPATH1$UPATH"
              2014-12-11 10:38:26 2-Warning   1   hostname.locDid not receive expected response to command: FPATH="$UPATH1$UPATH"
              2014-12-11 10:38:26 4-Debug 1   hostname.locWaiting for an echo of echo $FPATH command
              2014-12-11 10:38:26 4-Debug 1   hostname.locWaiting for a response to: echo $FPATH

               

              SSH.log

              iF5@hostname.loc:Active:In Sync] config # FTPHOST=IPADDRESS

              [F5@hostname.loc:Active:In Sync] config # HOST=$HOSTNAME

              [F5@hostname.loc:Active:In Sync] config # USER=F5

              [F5@hostname.loc:Active:In Sync] config # PASS=PASS

              [F5@hostname.loc:Active:In Sync] config # UPATH1=Config'/'Current'/'

              [F5@hostname.loc:Active:In Sync] config # UPATH=`date +%Y'/'%m'/'%d`

              [F5@hostname.loc:Active:In Sync] config # FPATH=$UPATH1$UPATH

              [F5@hostname.loc:Active:In Sync] config # echo $FPATH

              Config/Current/2014/12/11

              [F5@hostname.loc:Active:In Sync] config #

              [F5@hostname.loc:Active:In Sync] config #

              [F5@hostname.loc:Active:In Sync] config # cd /config

              [F5@hostname.loc:Active:In Sync] config # tmsh -c "save sys config base"

              cp bigip_base.conf $HOST.conf

              ftp -inv << EOF

              open $FTPHOST

              user $USER $PASS

              bin

              put /config/$HOST.conf $FPATH/$HOST.conf.txt

              close

              bye

              EOFSaving running configuration...

                /config/bigip_base.conf

                /config/bigip_user.conf

                /config/partitions/DV-CUST/bigip_base.conf
              [F5@hostname.loc:Active:In Sync] config # cp bigip_base.conf $HOST.conf

              [F5@hostname.loc:Active:In Sync] config # ftp -inv << EOF

              > open $FTPHOST

              > user $USER $PASS

              > bin

              > put /config/$HOST.conf $FPATH/$HOST.conf.txt

              > close

              > bye

              > EOF

              Connected to IPADDRESS (IPADDRESS).

              220-FileZilla Server version 0.9.44 beta

              220-written by Tim Kosse (tim.kosse@filezilla-project.org)

              220 Please visit http://sourceforge.net/projects/filezilla/

              Remote system type is UNIX.

              331 Password required for f5

              230 Logged on

              200 Type set to I

              local: /config/hostname.loc.conf remote: Config/Current/2014/12/11/hostname.loc.conf.txt

              227 Entering Passive Mode (IPADDRESS,248,33)

              150 Opening data channel for file upload to server of "/Config/Current/2014/12/11/hostname.loc.conf.txt"

              226 Successfully transferred "/Config/Current/2014/12/11/hostname.loc.conf.txt"

              14700 bytes sent in 9.2e-05 secs (1.6e+05 Kbytes/sec)

              221 Goodbye

              [F5@hostname.loc:Active:In Sync] config #

              • Re: using bash commands in Device.CLI.Send Commands fails
                thijn

                Hi,

                Ofcourse... the logs, i should've included this into the original post.

                I have two logfiles.. one is the output of KiwiCattools., the other is the output as seen in a SSH session.

                 

                 

                Kiwicattools log

                2014-12-11 10:35:51 3-Info 0 Kiwi CatTools Service Performing activity - Run Now

                2014-12-11 10:35:52 3-Info 0 Kiwi CatTools Service Loading activity: Backup F5. Schd: 36

                2014-12-11 10:35:52 4-Debug 0 Kiwi CatTools Service Marshaller - Running script. Device: hostname.log

                2014-12-11 10:35:53 4-Debug 1 hostname.log.SSH Fingerprint: 8b:7c:0a:21:9d:3d:6d:6b:5f:db:6a:1c:10:a8:88:8d

                2014-12-11 10:35:53 4-Debug 1 hostname.log.Connected to 10.0.0.1

                2014-12-11 10:35:53 4-Debug 1 hostname.log.Login F5 Big IP: hostname.loc

                2014-12-11 10:35:53 4-Debug 1 hostname.log.Waiting for command prompt

                2014-12-11 10:35:53 4-Debug 1 hostname.log.DeviceHostnameID: [USER@hostname.loc:Standby:In Sync] ~

                2014-12-11 10:35:53 4-Debug 1 hostname.log.Login to hostname.log.was successful

                2014-12-11 10:35:54 4-Debug 1 hostname.log.Waiting for an echo of #!/bin/bash command

                2014-12-11 10:35:54 4-Debug 1 hostname.log.Waiting for a response to: #!/bin/bash

                2014-12-11 10:35:54 4-Debug 1 hostname.log.Waiting for a response to:

                2014-12-11 10:35:54 4-Debug 1 hostname.log.Waiting for an echo of FTPHOST=IPADDRESS command

                2014-12-11 10:35:54 4-Debug 1 hostname.log.Waiting for a response to: FTPHOST=IPADDRESS

                2014-12-11 10:35:54 4-Debug 1 hostname.log.Waiting for an echo of HOST=$HOSTNAME command

                2014-12-11 10:35:54 4-Debug 1 hostname.log.Waiting for a response to: HOST=$HOSTNAME

                2014-12-11 10:35:54 4-Debug 1 hostname.log.Waiting for an echo of USER=F5 command

                2014-12-11 10:35:55 4-Debug 1 hostname.log.Waiting for a response to: USER=F5

                2014-12-11 10:36:25 2-Warning 1 hostname.log.Did not receive expected response to command: USER=F5

                2014-12-11 10:36:25 4-Debug 1 hostname.log.Waiting for an echo of PASS=PASS command

                2014-12-11 10:36:25 4-Debug 1 hostname.log.Waiting for a response to: PASS=PASS

                2014-12-11 10:36:55 2-Warning 1 hostname.log.Did not receive expected response to command: PASS=PASS

                2014-12-11 10:36:55 4-Debug 1 hostname.log.Waiting for an echo of UPATH1=Config'/'Current'/' command

                2014-12-11 10:36:55 4-Debug 1 hostname.log.Waiting for a response to: UPATH1=Config'/'Current'/'

                2014-12-11 10:37:25 2-Warning 1 hostname.log.Did not receive expected response to command: UPATH1=Config'/'Current'/'

                2014-12-11 10:37:25 4-Debug 1 hostname.log.Waiting for an echo of UPATH=`date +%Y'/'%m'/'%d` command

                2014-12-11 10:37:25 4-Debug 1 hostname.log.Waiting for a response to: UPATH=`date +%Y'/'%m'/'%d`

                2014-12-11 10:37:55 2-Warning 1 hostname.log.Did not receive expected response to command: UPATH=`date +%Y'/'%m'/'%d`

                2014-12-11 10:37:55 4-Debug 1 hostname.log.Waiting for an echo of FPATH="$UPATH1$UPATH" command

                2014-12-11 10:37:55 4-Debug 1 hostname.log.Waiting for a response to: FPATH="$UPATH1$UPATH"

                2014-12-11 10:38:26 2-Warning 1 hostname.log.Did not receive expected response to command: FPATH="$UPATH1$UPATH"

                2014-12-11 10:38:26 4-Debug 1 hostname.log.Waiting for an echo of echo $FPATH command

                2014-12-11 10:38:26 4-Debug 1 hostname.log.Waiting for a response to: echo $FPATH

                2014-12-11 10:38:56 2-Warning 1 hostname.log.Did not receive expected response to command: echo $FPATH

                2014-12-11 10:38:56 4-Debug 1 hostname.log.Waiting for a response to:

                2014-12-11 10:39:26 2-Warning 1 hostname.log.Did not receive expected response to command:

                2014-12-11 10:39:26 4-Debug 1 hostname.log.Waiting for a response to:

                2014-12-11 10:39:56 2-Warning 1 hostname.log.Did not receive expected response to command:

                2014-12-11 10:39:56 4-Debug 1 hostname.log.Waiting for an echo of cd /config command

                2014-12-11 10:39:56 4-Debug 1 hostname.log.Waiting for a response to: cd /config

                2014-12-11 10:40:26 2-Warning 1 hostname.log.Did not receive expected response to command: cd /config

                2014-12-11 10:40:26 4-Debug 1 hostname.log.Waiting for an echo of tmsh -c "save sys config base" command

                2014-12-11 10:40:26 4-Debug 1 hostname.log.Waiting for a response to: tmsh -c "save sys config base"

                2014-12-11 10:40:58 2-Warning 1 hostname.log.Did not receive expected response to command: tmsh -c "save sys config base"

                2014-12-11 10:40:58 4-Debug 1 hostname.log.Waiting for an echo of cp bigip_base.conf $HOST.conf command

                2014-12-11 10:40:58 4-Debug 1 hostname.log.Waiting for a response to: cp bigip_base.conf $HOST.conf

                2014-12-11 10:41:28 2-Warning 1 hostname.log.Did not receive expected response to command: cp bigip_base.conf $HOST.conf

                2014-12-11 10:41:28 4-Debug 1 hostname.log.Waiting for an echo of ftp -inv << EOF command

                2014-12-11 10:41:28 4-Debug 1 hostname.log.Waiting for a response to: ftp -inv << EOF

                2014-12-11 10:41:58 2-Warning 1 hostname.log.Did not receive expected response to command: ftp -inv << EOF

                2014-12-11 10:41:58 4-Debug 1 hostname.log.Waiting for an echo of open $FTPHOST command

                2014-12-11 10:41:58 4-Debug 1 hostname.log.Waiting for a response to: open $FTPHOST

                2014-12-11 10:42:28 2-Warning 1 hostname.log.Did not receive expected response to command: open $FTPHOST

                2014-12-11 10:42:29 4-Debug 1 hostname.log.Waiting for an echo of user $USER $PASS command

                2014-12-11 10:42:29 4-Debug 1 hostname.log.Waiting for a response to: user $USER $PASS

                2014-12-11 10:42:59 2-Warning 1 hostname.log.Did not receive expected response to command: user $USER $PASS

                2014-12-11 10:42:59 4-Debug 1 hostname.log.Waiting for an echo of bin command

                2014-12-11 10:42:59 4-Debug 1 hostname.log.Waiting for a response to: bin

                2014-12-11 10:43:29 2-Warning 1 hostname.log.Did not receive expected response to command: bin

                2014-12-11 10:43:29 4-Debug 1 hostname.log.Waiting for an echo of mkdir $FPATH command

                2014-12-11 10:43:29 4-Debug 1 hostname.log.Waiting for a response to: mkdir $FPATH

                2014-12-11 10:43:59 2-Warning 1 hostname.log.Did not receive expected response to command: mkdir $FPATH

                2014-12-11 10:43:59 4-Debug 1 hostname.log.Waiting for an echo of put /config/$HOST.conf /$FPATH/$HOST.txt command

                2014-12-11 10:43:59 4-Debug 1 hostname.log.Waiting for a response to: put /config/$HOST.conf /$FPATH/$HOST.txt

                2014-12-11 10:44:29 2-Warning 1 hostname.log.Did not receive expected response to command: put /config/$HOST.conf /$FPATH/$HOST.txt

                2014-12-11 10:44:29 4-Debug 1 hostname.log.Waiting for an echo of close  command

                2014-12-11 10:44:29 4-Debug 1 hostname.log.Waiting for a response to: close

                2014-12-11 10:45:00 2-Warning 1 hostname.log.Did not receive expected response to command: close

                2014-12-11 10:45:00 4-Debug 1 hostname.log.Waiting for an echo of bye command

                2014-12-11 10:45:00 4-Debug 1 hostname.log.Waiting for a response to: bye

                2014-12-11 10:45:30 2-Warning 1 hostname.log.Did not receive expected response to command: bye

                2014-12-11 10:45:30 4-Debug 1 hostname.log.Waiting for an echo of EOF command

                2014-12-11 10:45:30 4-Debug 1 hostname.log.Waiting for a response to: EOF

                2014-12-11 10:46:00 2-Warning 1 hostname.log.Did not receive expected response to command: EOF

                2014-12-11 10:46:00 3-Info 1 hostname.log.Command results: 4 of 24, 20

                2014-12-11 10:46:00 4-Debug 1 hostname.log.Disconnecting from hostname.loc

                2014-12-11 10:46:00 4-Debug 1 hostname.log.Disconnected from 10.0.0.1

                2014-12-11 10:46:00 3-Info 0 Kiwi CatTools Service All threads have finished. Now processing results...

                2014-12-11 10:46:00 4-Debug 0 Kiwi CatTools Service Writing sortable HTML report to: C:\Program Files\CatTools3\Reports\Device.CLI.Send commands.htm

                2014-12-11 10:46:00 3-Info 0 Kiwi CatTools Service Run Now activity has completed

                2014-12-11 11:14:22 3-Info 0 Kiwi CatTools Manager Program shutdown (Manager Mode)

                2014-12-11 11:14:22 3-Info 0 Kiwi CatTools Service Starting scheduler

                2014-12-11 11:14:22 4-Debug 0 Kiwi CatTools Service Loading activity schedule times from database.

                2014-12-11 11:14:22 3-Info 0 Kiwi CatTools Service Scheduling timer activated

                2014-12-11 12:53:09 3-Info 0 Kiwi CatTools Manager Program start-up

                2014-12-11 12:53:09 3-Info 0 Kiwi CatTools Manager Running in Manager Mode

                2014-12-11 12:53:09 3-Info 0 Kiwi CatTools Manager Version: 3.4.0

                2014-12-11 12:53:09 4-Debug 0 Kiwi CatTools Manager Attempting open of database: C:\Program Files\CatTools3\KiwiDB-CatTools.kdb

                2014-12-11 12:53:09 3-Info 0 Kiwi CatTools Manager Database Connected OK

                2014-12-11 12:53:10 3-Info 0 Kiwi CatTools Manager Protocol Engine 2.6.8.84 enabled

                2014-12-11 12:53:10 3-Info 0 Kiwi CatTools Manager Mail Server installed

                2014-12-11 12:53:10 3-Info 0 Kiwi CatTools Manager Start-up completed

                 

                 

                SSH log

                F5@hostname.loc:Active:In Sync] config # FTPHOST=IPADDRESS

                [F5@hostname.loc:Active:In Sync] config # HOST=$HOSTNAME

                [F5@hostname.loc:Active:In Sync] config # USER=F5

                [F5@hostname.loc:Active:In Sync] config # PASS=PASS

                [F5@hostname.loc:Active:In Sync] config # UPATH1=Config'/'Current'/'

                [F5@hostname.loc:Active:In Sync] config # UPATH=`date +%Y'/'%m'/'%d`

                [F5@hostname.loc:Active:In Sync] config # FPATH=$UPATH1$UPATH

                [F5@hostname.loc:Active:In Sync] config # echo $FPATH

                Config/Current/2014/12/11

                [F5@hostname.loc:Active:In Sync] config #

                [F5@hostname.loc:Active:In Sync] config #

                [F5@hostname.loc:Active:In Sync] config # cd /config

                [F5@hostname.loc:Active:In Sync] config # tmsh -c "save sys config base"

                cp bigip_base.conf $HOST.conf

                ftp -inv << EOF

                open $FTPHOST

                user $USER $PASS

                bin

                put /config/$HOST.conf $FPATH/$HOST.conf.txt

                close

                bye

                EOFSaving running configuration...

                  /config/bigip_base.conf

                  /config/bigip_user.conf

                  /config/partitions/DV-CUST/bigip_base.conf

                [F5@hostname.loc:Active:In Sync] config # cp bigip_base.conf $HOST.conf

                [F5@hostname.loc:Active:In Sync] config # ftp -inv << EOF

                > open $FTPHOST

                > user $USER $PASS

                > bin

                > put /config/$HOST.conf $FPATH/$HOST.conf.txt

                > close

                > bye

                > EOF

                Connected to IPADDRESS (IPADDRESS).

                220-FileZilla Server version 0.9.44 beta

                220-written by Tim Kosse (tim.kosse@filezilla-project.org)

                220 Please visit http://sourceforge.net/projects/filezilla/

                Remote system type is UNIX.

                331 Password required for f5

                230 Logged on

                200 Type set to I

                local: /config/hostname.loc.conf remote: Config/Current/2014/12/11/hostname.loc.conf.txt

                227 Entering Passive Mode (IPADDRESS,248,33)

                150 Opening data channel for file upload to server of "/Config/Current/2014/12/11/hostname.loc.conf.txt"

                226 Successfully transferred "/Config/Current/2014/12/11/hostname.loc.conf.txt"

                14700 bytes sent in 9.2e-05 secs (1.6e+05 Kbytes/sec)

                221 Goodbye

                [F5@hostname.loc:Active:In Sync] config #