Create a function to open the telnet
session to the switchname given by the first argument (or to your default switchname if no argument is provided), e.g. in .bashrc
you could do:
mytelnet() {
local swname=${1:-defaultname} ## use local vars within function
telnet $swname.compname.com ## connect to your switch
}
Then create the alias
you want for enter
, e.g.
alias enter='mytelnet'
Now at the command line you can type:
$ enter ## to go to defaultname.compname.com
or
$ enter switchname ## to go to switchname.compname.com
For testing you can just enter the function and alias on the command line, e.g.
$ mytelnet() { local swname=${1:-defaultname}; telnet $swname.compname.com; }
$ alias enter='mytelnet'
Then telnet away...
(note: you can simply name your function enter()
and do away with the alias
. I just find it convenient to define my functions at the top of my .bashrc
and then create aliases, as needed, in the various sections below, but using an alias is by no means a requirement)