       if { $app == "nsm" } { 
         expect timeout {
           set timeout 60
+        } "*# " {
+          send "exit\r"
+          exp_continue
         } "*$ " { 
           send "exit\r" 
           sleep 1

#!/usr/bin/expect -f

# $Id$

set send_slow {10 .01}
set timeout 60

  send -s "sudo su -\r"
  exp_continue
} "*# " {
  send "echo \${SHELL}\r"
}

expect "*#" {
  if { ! [regexp "bash" $expect_out(buffer)] } {
    send -s "bash\r"
  } else {
    send "\r"
  }
}

expect "*#" {
  send -s "uname\r"
}

expect "*#" {
  if { [regexp "Linux" $expect_out(buffer)] } {
    set os "Linux"
  } elseif { [regexp "SunOS" $expect_out(buffer)] } {
    set os "SunOS"
  } else {
    return
  }
  send "\r"
}

expect "*#" {
  if { $os == "Linux" } {
    if { $app == "nsm" } {
      send -s "unset TMOUT;ln -sf /usr/share/zoneinfo/Europe/Amsterdam /etc/localtime;ntpdate -u 172.30.73.133;hwclock --systohc\r"
    }
  } elseif { $os eq "SunOS" } {
    send "ntpdate -u 172.30.73.133\r"
  } else {
    send "\r"
  }
}


if { $app == "nsm" } {
  expect "*#" {
    if { $os == "Linux" } {
      send -s "ifconfig | perl -nle'/dr:(172.30.\\S+)/&&print\$1'\r"
    } elseif { $os == "SunOS" } {
      send -s "ifconfig -a | perl -nle'/net (172.30.\\S+)/&&print\$1'\r"
    }
  }

  expect "*#" {
