Bulk deletion of CTL/ITL files

So I created a forking version that will do all the phones you would like in a single command.  Granted this uses tcl (non-threaded) and expect to call the fork.

#!/usr/bin/expect
set commandList {SETTINGS CTL UNLOCK ERASE}
set phoneIPList {192.168.1.1 192.168.1.2}
set user "User"
set pass "Password"
foreach phoneIP [split $phoneIPList] {
      set pid [fork]
        exit -onexit {
                exec kill [pid]
        }
        switch $pid {
                -1 {
                        puts "Fork attempt #$i failed."
                }
                0 {
                        foreach command [split $commandList] {
                                        if {$command == "ERASE"} {
                                                after 5000
                                        }
                                        if { [catch { exec curl -i --user $user\:$pass \
                                        -0 --data-urlencode XML@$command\.xml \
                                        $phoneIP\/CGI/Execute } msg] } {
                                                puts $msg
                                        }
                        }
                        exit
                }
                default {
                }
        }
}



You will need 4 XML files named, SETTINGS.xml, CTL.xml, UNLOCK.xml , and ERASE.xml with the Key presses as follows:

<CiscoIPPhoneExecute>
        <ExecuteItem Priority='0' URL='Init:Services'/>
        <ExecuteItem Priority='0' URL='Key:Settings'/>
</CiscoIPPhoneExecute>

This is the SETTINGS.xml as an example you can figure out the rest though.  This has been used in production and the only caveat is some 79xx's need different softkeys as well as a reset from CUCM even though the CTL deletion normally resets the phone.

32 lines of code and a few XML files.  This should be good enough for most peoples needs.

Comments

  1. Hi Tim, would you mind helping me understand how to use this script?
    Cheers,
    Sam

    ReplyDelete
    Replies
    1. When I get a chance, I will probably post a full python version. I will probably exclude threading in my example to keep it simple. This was a TCL snippet I was using for 79xx phones but I need to write a newer version for the 88xx series.

      Delete

Post a Comment

Popular posts from this blog

Policy Based Routing on a Nexus

Adding 2 Factor Authentication to Guacamole through Duo and Yubikey