For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Merry95_171142's avatar
Merry95_171142
Icon for Nimbostratus rankNimbostratus
Dec 01, 2014

run a list of tmsh commands (copy - paste) failed

Hello,

 

I have created an automatic VBA script to generate a list of pool from a .xls file.

 

It codes a list of commands tmsh to create the associated pools. The list is written in txt format in a text editor.

 

I tried to copy paste these commands, (~ 70 lines), but almost half doesn't paste correctly.

 

Is there a way to import this text file in F5, and then from the cli, execute the commands in it, so I don't lose anything?

 

Or an other way to paste my list of command correctly?

 

10 Replies

  • Did you try this in tmsh? load sys config from-terminal merge

     

  • shaggy's avatar
    shaggy
    Icon for Nimbostratus rankNimbostratus

    if you have bash access on the F5 (from tmsh, run "run /util bash"), you can create and execute a bash script out of the tmsh commands:

    1. preface each command with "tmsh" so each command can be run from bash
    2. add !/bin/bash as the first line of the text file
    3. upload the file containing the commands to /shared/(filename).sh using SCP
    4. from bash on the f5, make the script executable
      chmod 755 /shared/(filename).sh
    5. execute the script
      bash /shared/(filename).sh
    6. once you validate that the resulting configuration is what you desired/expected, save the config
      tmsh save /sys config partitions all

    i often use this instead of copying/pasting commands as error output is the only thing output to the screen and is not lost among the list of commands being run

    • mushair_264331's avatar
      mushair_264331
      Icon for Nimbostratus rankNimbostratus
      Hey Shaggy, Hope you can help here. my test file has this: !/bin/bash tmsh save /sys ucs backup I am getting "line: 3) incomplete command" And If I remove "" from line 2 i get: line: 2) "tmsh" unexpected argument.
  • if you have bash access on the F5 (from tmsh, run "run /util bash"), you can create and execute a bash script out of the tmsh commands:

    1. preface each command with "tmsh" so each command can be run from bash
    2. add !/bin/bash as the first line of the text file
    3. upload the file containing the commands to /shared/(filename).sh using SCP
    4. from bash on the f5, make the script executable
      chmod 755 /shared/(filename).sh
    5. execute the script
      bash /shared/(filename).sh
    6. once you validate that the resulting configuration is what you desired/expected, save the config
      tmsh save /sys config partitions all

    i often use this instead of copying/pasting commands as error output is the only thing output to the screen and is not lost among the list of commands being run

    • mushair_264331's avatar
      mushair_264331
      Icon for Nimbostratus rankNimbostratus
      Hey Shaggy, Hope you can help here. my test file has this: !/bin/bash tmsh save /sys ucs backup I am getting "line: 3) incomplete command" And If I remove "" from line 2 i get: line: 2) "tmsh" unexpected argument.
  • Thank you G.Scott Harris

    It seems

     load sys config file my_file.txt verify 
    and

    load sys config file my_file.txt merge 
    can do what I want. Unfortunately, it doesnt understand the command 'cd /partition'

    Thank you shaggy.

    I tried your way, but I get this message error:

    "yntax Error: invalid property value "state":"up}}

    The line is :

    create ltm pool E3_Akio_8236 monitor http load-balancing-mode least-connections-member members add { sprjvihs01:8236 sprjvihs02:8236 {state user-up}}

    I tried to adapt the line with no success...

    What finally works in my case is :

    tmsh < script.txt 

    That's the simplest way and it works so it suits me 🙂

    • shaggy's avatar
      shaggy
      Icon for Nimbostratus rankNimbostratus
      out of curiosity, when you created the bash script, did you preface each tmsh command with "tmsh "? also want to note - merge is used to merge text that is formatted as config (not as tmsh commands) into the bigip configuration. instead of "create ltm virtual ... profiles add {..." you would format the config as "ltm virtual .... profiles {..." just as it would appear when running "list ltm virtual ..." commands. other commands like "cd" will not work because they are not config elements that would be merged. instead, you'd have to either merge the config into the proper destination partition ("cd /partition", "load sys config merge file/from-terminal") or you could change directories to "/Common/" or "/" and ensure that you reference every f5 object in your config with the full object-name (/partition/object_vs)
    • Merry95_171142's avatar
      Merry95_171142
      Icon for Nimbostratus rankNimbostratus
      The script is created with lines like I'va written above, ie without "tmsh" in front of. But it's definitely a command list, and not a config file like when running "list ltm virtual ..." Thank you for your piece of advice! I will think of it next time.
  • You can't use the cd command inside a config file. Instead the name of the object should include the full path like this:

    /partition/object_name
    
  • Dear All, I need to migrate F5 8900 to i7800, please help to get shorter way to copy all config from existing device to new device. I have already tried with UCS file and bypassed platform and licence but still got error. Please provide solution.