Script Hangs!

Hi,
I have script which is based on TCL and expect. It is written to test my code. It usually runs fine for a while and hangs after sometime.

Code snippet

    set l\_temp_timeout $timeout
    OUTPUT_LOG2 2 >>>$expect_out\(buffer\)<<<
    OUTPUT_LOG2 2 "Expecting...$my_prompt"
    set timeout 3
    
    expect  \{
        $my_prompt \{ set l 1 \}
        timeout  \{ OUTPUT_LOG2 2 $expect_out\(buffer\) \}
    \}
    OUTPUT_LOG2 2 "...Out of Expect $my_prompt"

My log for this code normally looks like

Retrying...
>>>^M^M
238114.0^M
^Mswitch(config-if-hsrp)#<<<
Expecting...#
...Out of Expect #

But once this hangs, it looks like

Retrying...
>>>^M^M
704802.0^M
^Mswitch(config-if-hsrp)#<<<
Expecting...#

 Screen shot for this

^Mswitch(config-if-hsrp)# echo 704802.0^M
704802.0
^Mswitch(config-if-hsrp)# sh ip route vrf all^M
sh ip route vrf all

IP Route Table for VRF "default"
:
:
:
:
IP Route Table for VRF "cisco3"
'*' denotes best ucast next-hop '**' denotes best mcast next-hop
'[x/y]' denotes [preference/metric]

0.0.0.0/32, 1 ucast next-hops, 0 mcast next-hops
*via Null0, [220/0], 00:25:03, local, discard
255.255.255.255/32, 1 ucast next-hops, 0 mcast next-hops
*via sup-eth1, [0/0], 00:25:03, local

Even I noticed that the prompt did not come back. Not sure whats the problem. Even if the prompt which is "#" did not show up, at least it should have timed out.

Why is it hanging ?

Can you please help ?

Thanks
Naveen

Start the script with -d option or turn on exp_internal for a large amount of trace information. Also see Debugging Expect programs

As this is combo of TCL and Expect I am doing this inside the script.

# #!/usr/bin/tclsh
package require Expect

Where should I give the -d option ?

I run the script as tclsh <scripe-file-name>

Thanks
Naveen