Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread Display Modes
Old Dec 26, 2012, 06:51 AM   #1
macrumors newbie
Join Date: Dec 2012
HELP Applescript for telnet

Hello everyone.

I would like to know correct script for telnet connection.
Below script is one I made. But it is not working.
Especially I don't know what I should use keyword or command on red part.

launch "iTerm"
tell application "iTerm"
	set myterm to (make new terminal)
	tell myterm
		launch session "Default Session"
		tell the last session
			write text "telnet 2001"
			write text "enable"
			write text "password"
			write text "reload"
			if output = "System configuration has been modified. Save? [yes/no]:" then
				write text "n"
			else if output = "Proceed with reload? [confirm]" then
				write text "y"
			end if
		end tell
	end tell
end tell
Please teach me how solve this problem.
Thank you for your attention.

Last edited by OllyW; Dec 26, 2012 at 12:45 PM. Reason: Please use code tags
SOOMINAHN is offline   0 Reply With Quote
Old Feb 10, 2013, 07:45 PM   #2
macrumors regular
Join Date: Jul 2002
Location: OR
As you already know, your output lines won't work.

The 2 ways that this could work (but doesn't) is as follows:
1) The "write text 'blah, blah, blah" line would return a value which is either an empty string for a command that was accepted or the text that the process the terminal is communicating with returned. iTerm doesn't do this. "Write" does not return anything.

2) iTerm provides a "contents" property of the "session". This sounds like it would return all of the text of the session and you would have to sort though that looking for the last line. When I ran it got back nothing. The compiler even changed my "get contents" to "get text" inside of my "tell last session" block.

What you might be left with is using System Events to do a command-a, command-c to get the contents of the window to the clipboard and then pick through that to find out what the last line of text contains.
numero is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
OS-neutral: Telnet/Text adventure games Astroboy907 Mac and PC Games 8 Feb 23, 2014 12:27 PM
Telnet Banner? SSH Post-Login Message? AmestrisXServe OS X 1 Feb 9, 2014 11:48 AM
AppleScript: How do I save multiple Excel sheets to one pdf using Applescript sbtaylor1 Mac Applications and Mac App Store 0 Oct 28, 2013 11:32 PM
vSSH - SSH and Telnet client for Mac OS X Velestar Mac Applications and Mac App Store 0 Feb 1, 2013 04:09 AM
Xcode telnet code MagicJordan iPhone/iPad Programming 0 Oct 8, 2012 05:01 PM

Forum Jump

All times are GMT -5. The time now is 05:41 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2015, MacRumors.com, LLC