Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Scripting help

Scripting help
Thread Tools
Forum Regular
Join Date: Jun 2003
Location: California
Status: Offline
Reply With Quote
Jun 28, 2003, 02:51 PM
 
My first post, here we go:
I'm writing an apple script to launch telnet within the terminal then connect to a server so I do not have to do this everytime I wish to connect to the server. I have gotten the terminal to open telnet, but I cannot get it to tell telnet "open (IP number)". This is what I have so far:

tell application "Terminal"
activate
do script with command "telnet"
(don't know what to put here to tell telnet to open an IP)
tell window 1
set background color to "black"
set cursor color to "green"
set normal text color to "green"
set bold text color to "green"
set number of columns to 80
set number of rows to 40
end tell
end tell

Any help would be appreciated.
     
Forum Regular
Join Date: Jun 2001
Location: San Francisco
Status: Offline
Reply With Quote
Jun 28, 2003, 03:32 PM
 
do script with command "telnet 127.0.0.1"
Let Déjà Vu take care of backing up your files.
You've got better things to do with your time.
http://propagandaprod.com/dejavu.html
     
Mac Elite
Join Date: May 1999
Location: San Jose, CA
Status: Offline
Reply With Quote
Jun 28, 2003, 03:41 PM
 
Actually, the 'with command' parameter id deprecated and should no longer be used. While it does still work now, it may not in future versions.

The 'correct' way is simply:

Code:
tell application "Terminal" do script "telnet 1.2.3.4" -- or whatever IP address end tell
The alternative is to save a terminal session and open that directly.

Use File -> New Command to execute a terminal command in a new window (in this case, your telnet command). Set the window settings, size, colors, etc. to whatever you want, then save the window (File -> Save).

The resulting .term file will contain all the parameters about that window, including position, size, colors, etc, and the fact that the telnet command was used to initiate it. You can then open that .term file and reset all those options:

Code:
tell application "Finder" open "path:to:file.term" using application "Terminal" end tell
viola.

If you save the .term file in ~/Library/Application Support/Terminal/ it'll be available in the Terminal's File -> Library menu for quick access, too.
Gods don't kill people - people with Gods kill people.
     
Xeo
Moderator Emeritus
Join Date: Mar 2001
Location: Austin, MN, USA
Status: Offline
Reply With Quote
Jun 28, 2003, 05:28 PM
 
Originally posted by Camelot:
viola.

     
Forum Regular
Join Date: Jun 2003
Location: California
Status: Offline
Reply With Quote
Jun 29, 2003, 01:44 PM
 
Thank you for all the help so fast, but I have one last question. I tried saving the session like you suggested but it won't save so I'm logged all the way in, so I have chosen to use an applescript. What script would I use to tell it to type in my password then hit enter?
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 08:09 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2