Forum Discussion
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
- jaikumar_f5
Noctilucent
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.
- Joel_Breton
Nimbostratus
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.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com