[HPADM] Trouble Using Expect to Telnet from HP-UX 11.00 to Windows

From: Dave T. (davidlt77_at_hotmail.com)
Date: 10/15/03

  • Next message: Dave T.: "[HPADM] SUMMARY: Melding Development & Production Environments on a VA7410"
    To: hpux-admin@dutchworks.nl
    Date: Wed, 15 Oct 2003 13:43:03 -0400
    
    

    I'm hoping someone on the HP-UX list has enough experience with expect to
    point me in the correct direction. I wrote an expect script to do the
    following:

    1. Telnet from HP-UX 11.00 to Windows.
    2. Execute a script on the Windows server and exit.

    I posted the following on a newsgroup for expect, and I didn't get any
    responses:

    I've written the expect script below:

    #!/usr/local/bin/expect -b

    exp_internal 1

    set timeout 10

    spawn telnet server 1023
    expect "login: "
    send ""
    expect "telnet> "
    send "mode character\r\r"
    expect "login: "
    send "krservice\r"
    expect "password: "
    send "abcdefg\r"
    expect "D:\RemoteScript>"
    send "stopapp.bat\r"
    wait
    expect "D:\RemoteScript>"
    send "exit\r"

    exit

    This script produces the following:

    spawn telnet server 1023
    parent: waiting for sync byte
    parent: telling child to go ahead
    parent: now unsynchronized from child
    spawn: returns {27301}

    expect: does "" (spawn_id exp5) match glob pattern "login: "? no
    Trying...

    expect: does "Trying...\r\n" (spawn_id exp5) match glob pattern
    "login: "? no
    Connected to server.
    Escape character is '^]'.

    expect: does "Trying...\r\nConnected to server.\r\nEscape character is
    '^]'.\r\n" (spawn_id exp5) match glob pattern "login: "? no
    Microsoft (R) Windows (TM) Version 5.00 (Build 2195)
    Welcome to Microsoft Telnet Service
    Telnet Server Build 5.00.992
    expect: does "Trying...\r\nConnected to server.\r\nEscape character is
    '^]'.\r\nMicrosoft (R) Windows (TM) Version 5.00 (Build
    2195)\r\r\nWelcome to Microsoft Telnet Service \r\r\nTelnet Server
    Build 5.00.992" (spawn_id exp5) match glob pattern "login: "? no
    06.1
    login:
    expect: does "Trying...\r\nConnected to server.\r\nEscape character is
    '^]'.\r\nMicrosoft (R) Windows (TM) Version 5.00 (Build
    2195)\r\r\nWelcome to Microsoft Telnet Service \r\r\nTelnet Server
    Build 5.00.99206.1\r\n\rlogin: " (spawn_id exp5) match glob pattern
    "login: "? yes
    expect: set expect_out(0,string) "login: "
    expect: set expect_out(spawn_id) "exp5"
    expect: set expect_out(buffer) "Trying...\r\nConnected to
    server.\r\nEscape character is '^]'.\r\nMicrosoft (R) Windows (TM)
    Version 5.00 (Build 2195)\r\r\nWelcome to Microsoft Telnet Service
    \r\r\nTelnet Server Build 5.00.99206.1\r\n\rlogin: "
    send: sending "\u001d" to { exp5 }

    expect: does "" (spawn_id exp5) match glob pattern "telnet> "? no

    expect: does "\n" (spawn_id exp5) match glob pattern "telnet> "? no
    telnet>
    expect: does "\ntelnet> " (spawn_id exp5) match glob pattern "telnet>
    "? yes
    expect: set expect_out(0,string) "telnet> "
    expect: set expect_out(spawn_id) "exp5"
    expect: set expect_out(buffer) "\ntelnet> "
    send: sending "mode character\r\r" to { exp5 }

    expect: does "" (spawn_id exp5) match glob pattern "login: "? no
    mode character

    expect: does "mode character\r\n\r\n" (spawn_id exp5) match glob
    pattern "login: "? no
    expect: timed out
    send: sending "krservice\r" to { exp5 }

    expect: does "mode character\r\n\r\n" (spawn_id exp5) match glob
    pattern "password: "? no
    ioctl error on TIOCREQCHECK: invalid argument
        while executing
    "expect "password: "
    "

    Obviously, the script isn't working. What am I doing wrong?

    Also, if anyone has a working autoexpect script on HP-UX, please send it to
    me. The one I have doesn't work.

    Thnx,

    Dave

    _________________________________________________________________
    Fretting that your Hotmail account may expire because you forgot to sign in
    enough? Get Hotmail Extra Storage today!
    http://join.msn.com/?PAGE=features/es

    --
                 ---> Please post QUESTIONS and SUMMARIES only!! <---
            To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl
           Name: hpux-admin@dutchworks.nl     Owner: owner-hpux-admin@dutchworks.nl
     
     Archives:  ftp.dutchworks.nl:/pub/digests/hpux-admin       (FTP, browse only)
                http://www.dutchworks.nl/htbin/hpsysadmin   (Web, browse & search)
    

  • Next message: Dave T.: "[HPADM] SUMMARY: Melding Development & Production Environments on a VA7410"

    Relevant Pages

    • Re: Hacker activity?
      ... >login to a server, most as root but some are attempts to login to ... >telnet, all come from the same remote server, and all fail. ... >getting some odd cgi calls to a script on a secure ssl server. ... Make sure root cannot login to your system via ssh. ...
      (freebsd-questions)
    • Re: Limit desktop & start menu
      ... Create a login script that runs when users log into the TS, and map the R: ... persisitent "R" drive on the server itself and that may cure it. ...
      (microsoft.public.windows.terminal_services)
    • Re: Slow TS logon from dumb terminals.
      ... Is a login from the console also slow? ... Do the users run a login script? ... if the Real-time protection component runs in every user session. ... No virus protection as only the server has s CD Rom/USB Access/Floppy. ...
      (microsoft.public.win2000.termserv.clients)
    • Re: Permission to execute jobs but nothing else
      ... Since this is being run on the server and kicked off by SQLAgent ... to run your script, no need for user name or password. ... > executes a CSCRIPT command pointing to this script on the ... > to me as long as I can setup a weak Login ID that can do ...
      (microsoft.public.sqlserver.security)
    • Re: Creating mapped drives from login script
      ... profiles that will use the altered login script. ... later reply to him/her regarding the server, ...
      (microsoft.public.windows.server.sbs)