Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Currently I do something like this:

telnet 23



cd /dir/

programname -s -g dosomething

I want to do this with one step, the coolest would be to compile a program for this using Automator, but i have no idea how to do that.
"shell script" in Automator fails at telnet 23 saying "connection refused" of course: I had no chance to type in password and so on.

Any ideas?

share|improve this question
any particular reason why you're using telnet, not ssh? – vartec Feb 15 '11 at 14:10
only telnet running on the remote machine (external windows server =/ ) – choise Feb 15 '11 at 14:15
good question I have to do the same thing with my modem - and no ssh – smashtastic Oct 15 '11 at 21:21
up vote 2 down vote accepted

When ssh isn't available, expect is typically used to automate access using telnet.

From the linked article:

#!/usr/bin/expect #Where the script should be run from.
set timeout 20 #If it all goes pear shaped the script will timeout after 20 seconds.
set name [lindex $argv 0] #First argument is assigned to the variable name
set user [lindex $argv 1] #Second argument is assigned to the variable user
set password [lindex $argv 2] #Third argument is assigned to the variable password
spawn telnet $name #This spawns the telnet program and connects it to the variable name
expect "login:" #The script expects login
send "$user " #The script sends the user variable
expect "Password:" #The script expects Password
send "$password " #The script sends the password variable
interact #This hands control of the keyboard over two you (Nice expect feature!)
share|improve this answer

Then, if no sshd is installed, you could automate your telnet using expect, that you probably will have to install on your mac.

Expect is a tool primarily for automating interactive applications, such as telnet, ftp, passwd, fsck, rlogin, tip, and more. Expect really makes this stuff trivial. Expect is also useful for testing these applications. It is described in many books, articles, papers, and FAQs. There is an entire book on it available from O'Reilly.

See .

share|improve this answer

If the system running on has a sshd server running, then you could simply do

ssh username@ 'cd /dir/ ; programmname -s -g dosomething'

To check if you have sshd running on you could either just try it, or login using telnet as you do already and, if it's a unix/linux/maxosx try doing a

pgrep -fl sshd


ps -e | grep sshd


lsof -i :22

All of these above will either not find anything or give you a line showing that sshd is running.

share|improve this answer
poorly there is no ssh installed. and also its password saved – choise Feb 15 '11 at 15:00
It's a Windows server. – grawity Feb 15 '11 at 15:37
I hope you know that using telnet is very bad security wise. Your username and passwords are sent in plain through the network. Anyone with some computer knowledge sitting on that network would be able to read your username and password in few minutes. Try moving to ssh which also works on Windows. – rems Feb 15 '11 at 15:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.