[olug] Expect script help...

Daniel Linder dan at linder.org
Thu Aug 26 16:53:43 UTC 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Guy,

  Slightly off-topic but I figgured what the heck. :)

I am trying to automate login to a remote Unix system.  I have this
working when my laptop telnets directly to the remote system and the
expect script then ran a script on the remote server to set the $DISPLAY
variable.

The situation has changed and I now have to shell into an intermediate
unix system, then run "PowerBroker" to connect in to the final location.
When my script runs on the remote system now, it can only get the IP
address of the intermediate "PowerBroker" system but not my true
workstation.

Can some expect or Tcl guru give me some quick pointers to parse the
command output in the expect script to parse out my workstations IP
address so I can send it to a remote system?

Here is a snippet of my expect code:

  #!/usr/bin/expect
  #
  # Code to login to the first machine would be here...
  #
  send "who am i\n";
  # This returns:
  # linderd     pts/2     Aug 26 10:32   (10.120.15.88)
  set MYDISPLAY <what goes here?>
  #
  # Code to login to the second machine would be here...
  #
  # Now set my workstation DISPLAY variable...
  send "DISPLAY=[ $DISPLAY ]:0.0\n";

Thanks!

Dan

- - - - -
"I do not fear computer,
I fear the lack of them."
 -- Isaac Asimov

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFBLhWXNiBNyqUzGb8RAhfEAJ9IBkDLJoQDIvP+hVbfzZz7MjhhCACfbMaq
QNTWa0G/JrBFQdq6BgECIWw=
=h1Ct
-----END PGP SIGNATURE-----



More information about the OLUG mailing list