Telnet shortcut?

evildan

Super Moderator
Okay, newbie question, but is there a way to create a shortcut so instrad of typing this in the terminal:

Code:
telnet host.com

login: username
password: password

cd directory1/directory2/directory3

So I'm looking for a 1 command shortcut solution to login and get me to a specified directory.

Any help would be appreciated.
 
To log in with one command, you can use rlogin/slogin. And to get you to a particular directory, as fddi1 said, I guess you can use it in an expect script.

 
I would have said modify the file ~/.cshrc but I do not believe that this is an explicit script. So when you created an alias if would type your username after telnet had been terminated, etc...

Try a PERL, I don't know PERL tho... :rolleyes:
 
PERL itself will not telnet to a server, you would need to install a module called Net:Telnet that PERL will call for. It works quite well as I have written several scripts for work thet telnet to switches/routers and perform some maintenance.

Perhaps a shell script would be a soluition?
 
Create a shell script with the extension ".TERM", this will open in terminal by default when you double-click it. It might read something like this:

#!/usr/bin/sh
# Shell script to connect to Telnet host

telnet username@my.telnet.net


You'd still need to put in your password (I think expect could be used to get around this, not sure how)

Now what ???
 
I have nothing else to add to this, but if possible, use ssh, telnet is not encrypted, so it's highly unsecure if someone indeed is "listening"

oh, one more addition:

#!/usr/bin/sh
# Shell script to connect via ssh to host

ssh -l [username] [host]


that -l option logs you in with [username] to [host], I've not yet found a way to add the password...
save the file to your home-folder, and chmod 755 it.
you can later on run it in terminal with ./filename
 
Originally posted by symphonix
You'd still need to put in your password (I think expect could be used to get around this, not sure how)

I'm not familiar with Expect, but maybe you could use an include type statement to pull in the password from another file, with 600 permissions. Or maybe just make the Expect script 600. :)
 
Originally posted by evildan
Let's pretend I'm UNIX dumb... how would I go about writing and implementing a script?

;)

First of all, you need to install Expect. Expect is just like perl, but I don't believe it's installed by default in OS X. Anyway, you'll need tcl libraries for Expect too.

So once you have the software installed. O'Reiley has a very good book on how to write expect scripts. The thing you want to do is fairly easy. Once you are familir with the concept, it will probably take about 5 minutes to write the actual script.
 
Back
Top