May 21, 2012

A Reason to Use iTerm for Mac Os X.

I just started using iTerm for Mac Os X instead of Terminal.  The reason is mainly because I like the way the you can create a bookmark.  I use this to make my rack time more efficient, however it will also work nicely for common connections I use at work. 

Session
Here is what I did: First I created an expect script for each device in the pod I wanted to log into.  This lets me save the username and password so I dont have to keep typing it.  Once created, store them in a directory on your drive. Here is what they look like:
#!/usr/bin/expect --

spawn telnet Your-Terminal-Server-IP-or-Name Line-Number-Goes-Here

expect  "Username"
send "YourUsername\r"
expect  "Password"
send "YourPassword\r"
expect  "are"
send "\r"
interact;
Next open ITerm. Select “Bookmarks”
Microsoft Word
Select “Manage Bookmarks” Select the “+” button.
Bookmarks
Enter the name for the bookmark and drag the expect script that auto-logs you into the lab equipment and drop it into the command field. Then Click ok.
iTerm
You can now choose Command-B to view your bookmarks.  Double click the bookmark and you are in business.

Related Posts:

  • No Related Posts

Comments

  1. MBR says:

    Great idea, Brandon! Thanks for posting it.

    I expanded on your original script, to add an optional command line arg for the device identifier (r1, sw1, etc), and to read files for the values that change with each rack rental. The command line arg lets you use one expect script for all devices. Using the file system to store some values allows them to be updated easily from the command line without bothering with an editor: “echo foo >file”

    This all works fine with both iTerm and Terminal.app. In Terminal.app just set the shell startup command and “Window > Save Windows as Group…” You can save individual terminal settings with “Shell > Export Settings…” but that’s much slower to startup (a couple of minutes vs a few seconds).

    !/usr/bin/expect –

    #

    usage: ine [device]

    where device is r1, r2, etc

    #

    2009-01-19 Michael Rose mikerose@gmail.com

    Based on a script by Brandon Carroll

    gets [open $env(HOME)/INE_PASS] pass gets [open $env(HOME)/INE_RACK] rack

    set device [lindex $argv 0] set user “scrack$rack$device”

    spawn telnet racks.internetworkexpert.com expect “Username:” send “$user\r” expect “Password:” send “$pass\r” puts “\r” sleep 2 send “\r” interact;

  2. Brandon says:

    Mike- I dont know how I missed this comment but wanted to say: Great Job!

    Regards,

    Brandon

Speak Your Mind

*