Expect Modem Script hangs after a few runs????

wauger
wauger used Ask the Experts™
on
Hi All. I was hoping you could help me with a script problem. I have an expect script that runs nightly and simply dials our T1 modem pools and checks for a terminal server prompt to verify that the modems are answering correctly and the terminal servers are functioning as well.

The script use to run on an old SUN box simply dialing about 4 T1's (24 times of course). That old SUN box died and now I have it running on an Ultra 5 - Solaris 2.6. I had to redo the script a little but I got it running again and added some more T1's to test as well. Every since we moved it to run off of the Ultra 5 it behaves very strangly.

The script will run for about two days then on the thrird or fouth day just die because the modem hoses. The interesting part is that I cant even recover the modem! It creates a defunct process on the system that I cant kill and I must reboot the server in order to regain control of the modem port.

This is very frustrating. So my question is, what am I missing in the script that is making the modem hose after a few runs? Or could it possibly be that I dont have the modem configured on the box correctly? Thanks for any info you can provide.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
I think you have to use no time out in your expect script,

eg:

#expect "Password:"
expect -timeout -1 "fred@testbox's password:"
send "$pwd\n"
# No timeout
expect -timeout -1 eof

Author

Commented:
Thanks for your comment. I currently have a timeout of 30 hardcoded in the script. Do you think that it would take longer for the prompt to appear? Here is the proc within the scrip that does the dialing....

proc tolldial {number} {

  set send_slow {1 .2}
  set timeout 5
  send -s "+++"
  expect "OK" { exec sleep 1 }
  send "ATH\r\n"
  expect "OK" { exec sleep 5 }

  exec sleep 1
  send "ATDT${number}\r"
  set timeout 30
  expect \
    "*CONNECT*" { } \
    "*BUSY*" {
        global busy
        incr busy
        exec sleep 1
        send "ATH\r\n"
        expect "OK" { exec sleep 5 }
      return
    } \
    "*Username:*" {send "\r"} \
    timeout {
      global noconnect
      incr noconnect
      exec sleep 1
      send -s "+++"
      exec sleep 3
      send "at\r"
      expect "OK" {send "ATH\r"}
      expect "OK"
      return
    }
  set timeout 20
  expect \
    "*Username:*" {
        global success
        incr success
        exec sleep 1
        send -s "+++"
        expect "OK" { exec sleep 1 }
        send "ATH\r\n"
        expect "OK" { exec sleep 5 }
        return
    } \
    timeout {
        global noprompt
        incr noprompt
        exec sleep 1
        send -s "+++"
        expect "OK" { exec sleep 1 }
        send "ATH\r\n"
        expect "OK" { exec sleep 5 }
        return
    }
}
Sorry, I didn't read your whole question. It might has something to do with your serial port config. Could you please post the setting on the serial port and what type of modem you are using.

run admintool, to get the detail of the modem setting.

BTW, you  OS is very old, have you apply all the lastest Recommended Patch Clusters?

You can get it from SunSolve:
http://sunsolve.sun.com/pub-cgi/show.pl?target=home

I'm on annual leave till early next year, hopefully some one can help you out on this.

Good luck!
==========
yuzh
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

try to do a manual dial in to see if the connetion time takes longer or not?

Are you using the same modems  as before?

Author

Commented:
OK, here is the output from the admintool.

Serial Ports
Port: a
Port Monitor: zsmon
Service Tag: ttya
Comment: Modem - Bidirectional

Modify Serial Port
Template: Terminal - Hardwired
Port: a, service enabled
Options: Initialize Only - DISABLED
         Bidirectional - ENABLED
         Software Carrier - DISABLED
Expert Options: Create UTMP Entry - ENABLED
                Connect on Carrier - DISABLED
Baud Rate: 9600
Terminal Type: tvi925
Login Prompt: "login:"
Comment:  Modem - Bidirectional
Service Tag: ttya
Port Monitor Tag: zsmon
Service: /usr/bin/login
Stream Modules: ldterm, ttcompat
Timeout (secs): Never


Hope this helps. The modem is a Motorola UDS 28800. Thanks.




You Serial Port settings are looks fine. (You can increase the Baud Rate to a higher speed!).

I few things we need to chech in here:

1. Has the modem at the remote end been changed ?

2. Can you pleasse check the modem's register values (the one attached to the Ultra 5), not to use the default value,
and make sure that the followings are set: (Have a look at the modem manual to see what values to be set)

   2.1) enable hardware flow control
        disable software flow control
   2.2) set Hardware DTR
        Enable hardware Carrier detect
   2.3) Turn off command echo
   2.4) Check the Register valuse for "wait time for dial tone), likely Sn (check your modem manual, verify with maunal dial in to the remote site to see how long does it take to see the prompt in seconds !).

3. If all the above looks ok then we need to check OS patchs.

   It takes time to figure out modem problem.

   Good luck, you needed.

==========
yuzh


can't proove or test here, but yuzh's suggestion with

     -timeout -1

sounds reasonable, Remember the negative value for timeout !

Author

Commented:
Thanks everyone for your help. I will try the "timeout -1" option first to see if that helps. I will get back to you and award the points...

Author

Commented:
Actually I have a question about this. If I change the timeout to "forever" what happens if a modem hangs or a terminal server doesnt respond? Then the script will NEVER finish, right? This cant be good....
AFAIK following gets an event when the connection is lost (for example the modem hangs and did not send anything), but I have no idea hwo to implement it in you source:

     expect -timeout -1 eof
just have a look at my first comment, and use it as an example.

Author

Commented:
Ok, I have increased the timeout value 2 times its orignal value and it seems to be working so far...two days now. I will keep you posted. Thanks

Author

Commented:
Thanks a lot for your help. Looks like all I needed to do was increase the timer value. The script has been running for a record 5 days consecutively!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial