Operating System - HP-UX
1755627 Members
2967 Online
108836 Solutions
New Discussion юеВ

Re: How to define "telnet . port" ?

 
apichart
Advisor

How to define "telnet . port" ?

As we know, telnet 0 = telnet localhost
instead of using "0" ,how could we define dot(.) as localhost? For exmaple, "telnet . port" should mean "telnet localhost port".
6 REPLIES 6
Nicolas Dumeige
Esteemed Contributor

Re: How to define "telnet . port" ?

What about a shell alias

alias telocal='telnet localhost'
All different, all Unix
Mark Grant
Honored Contributor

Re: How to define "telnet . port" ?

I just got this to sort of work by defining an alias of "." for localhost. Somehow I suspect this isn't a good idea but it worked.
Never preceed any demonstration with anything more predictive than "watch this"
Mobeen_1
Esteemed Contributor

Re: How to define "telnet . port" ?

Can this be done in the local hosts file /etc/hosts instead of alias? I would have tried this, if i had a test system

rgds
Mobeen
Mark Grant
Honored Contributor

Re: How to define "telnet . port" ?

Mobeen,

I did my test using /etc/hosts.
Never preceed any demonstration with anything more predictive than "watch this"
Ralph Grothe
Honored Contributor

Re: How to define "telnet . port" ?

If your using a Bourne shell I would guess the dot (i.e. '.') can get a bit annoying in your syntax as it is an alias for the source command.
Otherwise you could probably come up with an evil hack like a function declaration for your shell such as

e.g.

telnet() {
if [ "$1" = '.' ]; then
/usr/bin/telnet localhost $*
else
/usr/bin/telnet $*
fi
}
Madness, thy name is system administration
Mobeen_1
Esteemed Contributor

Re: How to define "telnet . port" ?

Mark,
So does it work using /etc/hosts. I am curious, let me know the outcome of your testing

rgds
Mobeen