Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

Running multiple tmsh commands

I'm trying to run multiple commands to change the names of BIG-IP objects. I tried two methods without any success.

Method 1: Copy all the commands and paste in the putty session

Problem: When I paste the commands the putty session gets all messed up and the commands are not complete

[root@localhost:Active:Standalone] ~ # tmsh mv ltm node /mypart/10.1.1.1 /mypart/newname1
[root@localhost:Active:Standalone] ~ # tmsh
root@(localhost)(cfg-sync Standalone)(Active)(/Common)(tmos)# tmsh mv ltm node /mypart/10.1.1.2 /mypart/newname2    
Syntax Error: unexpected argument "tmsh"
root@(localhost)(cfg-sync Standalone)(Active)(/Common)(tmos)# tmsh m
Syntax Error: unexpected argument "tmsh"

Method 2: Create text file with all commands and launch it from bash

Problem: Invalid characters are added to the commands

[root@localhost:Active:Standalone] ~ # sh -x renamenodes.txt
+ tmsh -q mv ltm node /mypart/10.1.1.1 $'/mypart/newname1\r'
) is invalid.he requested object name (/mypart/newname1   

Content of renamenodes.txt

tmsh mv ltm node /mypart/10.1.1.1 /mypart/newname1
tmsh mv ltm node /mypart/10.1.1.2 /mypart/newname2
tmsh mv ltm node /mypart/10.1.1.3 /mypart/newname3
tmsh mv ltm node /mypart/10.1.1.4 /mypart/newname4
0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Well not sure which version you are running on. I'm on 11.x I dont see mv option to rename objects. Guess yours is 12.x or above. The issue you are seeing is pretty common when large content is pasted. So inputs gets jumbled. Like tmsh alone gets pasted and the rest commands again getting pasted. In your method 1, the tmsh was pasted, and again inside the tmos you cannot rerun tmsh command. hence the syntax error.

To avoid this use transaction.

tmsh
create cli transaction
mv ltm node /mypart/10.1.1.1 /mypart/newname1
mv ltm node /mypart/10.1.1.2 /mypart/newname2
mv ltm node /mypart/10.1.1.3 /mypart/newname3
mv ltm node /mypart/10.1.1.4 /mypart/newname4
submit cli transaction

Or you can paste 5 lines each in the bash itself and it should work smoothly. Then slowly increase your count to 10.

0
Comments on this Answer
Comment made 29-Jun-2017 by Joel Breton 213

I will give it a try, I have 230 lines to paste

The mv command was introduce in version 11.6 I think, it is disable by default

Here's the command to enable it

modify /sys db mcpd.mvenabled value true 

Thanks

1
Comment made 29-Jun-2017 by jaikumar_f5 1594

Thank you, will test it out.

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

I was able to fix Method 2 by removing tmsh from the text file and call the file with tmsh instead of sh.

[root@localhost:Active:Standalone] ~ # tmsh < renamenodes.txt

Content of renamenodes.txt

mv ltm node /mypart/10.1.1.1 /mypart/newname1
mv ltm node /mypart/10.1.1.2 /mypart/newname2
mv ltm node /mypart/10.1.1.3 /mypart/newname3
mv ltm node /mypart/10.1.1.4 /mypart/newname4

All 230 nodes were successfully renamed without issues.

0