Posts

Showing posts from January, 2015

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.