Forum Discussion

raytapay_75679's avatar
raytapay_75679
Icon for Nimbostratus rankNimbostratus
May 18, 2016

Input File Containing VIPs for Deletion int TCL Script

I have a long list of VIPs to delete and looking at the sample scripts on Dev Central I only see that the scripts pull the whole list of VIPs and then the operations are done on them. Preferably, I would like to do something like below where each VIP name is read from a file and deleted, unless someone thinks otherwise of a better way. If I go the file route, do I need to refer to the file with $tmsh::argv, or that's not needed?

 Read file to take VIP names
 
set infile [open "viplist.txt" r]

while { [gets $infile line] >= 0 } {

 as long as I'm not at the end of my file, take the value of VIP name and delete it as below
        tmsh::delete /ltm virtual $line

}
close $infile
  • I think that a basic bash script that invokes tmsh commands would be better for your task

    For a preparation, format your file as follows with a list of valid tmsh commands (vi search & replace can help with preparation):

    tmsh delete ltm virtual vsname1
    tmsh delete ltm virtual vsname2
    tmsh delete ltm virtual vsname3
    tmsh delete ltm virtual vsnameX
    

    Save it as 'deletevs.sh' file

    • Execute the file as bash script
      bash deletevs.sh -x
      , and wait until the labour is done
  • I think that a basic bash script that invokes tmsh commands would be better for your task

    For a preparation, format your file as follows with a list of valid tmsh commands (vi search & replace can help with preparation):

    tmsh delete ltm virtual vsname1
    tmsh delete ltm virtual vsname2
    tmsh delete ltm virtual vsname3
    tmsh delete ltm virtual vsnameX
    

    Save it as 'deletevs.sh' file

    • Execute the file as bash script
      bash deletevs.sh -x
      , and wait until the labour is done
    • raytapay_75679's avatar
      raytapay_75679
      Icon for Nimbostratus rankNimbostratus
      Thanks for the response. Actually, I went with Excel as my VI skills are not superb but I see your point.
  • I think that a basic bash script that invokes tmsh commands would be better for your task

    For a preparation, format your file as follows with a list of valid tmsh commands (vi search & replace can help with preparation):

    tmsh delete ltm virtual vsname1
    tmsh delete ltm virtual vsname2
    tmsh delete ltm virtual vsname3
    tmsh delete ltm virtual vsnameX
    

    Save it as 'deletevs.sh' file

    • Execute the file as bash script
      bash deletevs.sh -x
      , and wait until the labour is done
    • raytapay_75679's avatar
      raytapay_75679
      Icon for Nimbostratus rankNimbostratus
      Thanks for the response. Actually, I went with Excel as my VI skills are not superb but I see your point.