Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Currently I do something like this:

telnet 192.168.0.3 23

username

password

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 192.168.0.3 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
add comment

3 Answers

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
add comment

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 http://www.nist.gov/el/msid/expect.cfm .

share|improve this answer
add comment

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

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

To check if you have sshd running on 192.168.0.3 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

or

ps -e | grep sshd

or

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
1  
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
add comment

Your Answer

 
discard

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.