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 > Developer Center > AppleScripting OS 9!

AppleScripting OS 9!
Thread Tools
scotty321
Fresh-Faced Recruit
Join Date: Nov 1999
Location: Chicago, IL USA
Status: Offline
Reply With Quote
Nov 1, 1999, 04:16 PM
 
Hey guys -- I was throwing around this great idea in my head for an Outlook Express 5.0 / Mac OS 9 AppleScript, and was wondering if anyone wanted to script it, since I'm an AppleScript novice myself.

The new file sharing capabilities of OS 9 are great -- as you know, you can now share your hard drive via TCP/IP. This is wonderful for consultants like many of you who are constantly "on the road" and may have forgotten something on your hard drive. Instead of using Apple Remote Access to dial in slowly, you can use any high speed connection that you find at anyone's office to connect to your Mac. (Timbuktu does this, of course, but it requires you to install Timbuktu on whatever computer you're currently working on.)

So the hurdle is this: If you have a cable modem with a dynamic IP address, you may not always have your current IP address with you -- and as a result, you might not be able to log into your computer using TCP/IP File Sharing.

As you know, Netopia offers this free service as part of the Timbuktu package. They keep a server running on their website with a list of IP address matched to your email address. When you restart your computer, your IP address & email address are both automatically sent to their servers. Then, when you need to connect to your computer from the road, you simply launch Timbuktu Pro, type in your email address, and voila! It finds your IP address for you.

And there's services like dynip.com that will do this same service for you for a annual fee.

Eventually, I would really love to see Apple offer this service as part of the OS... just type in your email address into the "TCP/IP" control panel (or some other control panel), and your computer's IP will be automatically registered with Apple's "locator" web site every time you restart your machine.

But in the meantime, what I was thinking is this: Why not use AppleScript, along with the built-in scheduling features of Outlook Express 5.0, to automatically take care of this problem. Every morning, the AppleScript could generate an email message containing your current IP address. Then, the email message would be sent to another email account that you don't normally check (such as a dummy HotMail account). Then, whenever you're on the road and you need to find out what your current IP address is, you simply log into your HotMail account and see an entire slew of emails -- all acting as a "log" of your day-to-day IP addresses!

I think I've gotten the OE part of the script, I just don't know how to get the other part of the script (placing in the IP Address):

tell application "Outlook Express"
activate
run
make draft window with properties {to recipients:"[email protected]", subject:"Your current IP address is 123", content:"Your current IP address is 123"}
set theWindow to the front window
send theWindow
end tell

Thanks for any help!

See ya,
Scott

--------------------------
Scott Rose, President
Scott's Software Solutions
Your FileMaker Pro Experts Since 1992

(323) 954-1978
(253) 736-7627 fax http://www.scottworld.com
     
MacCanada
Junior Member
Join Date: Oct 1999
Location: Edmonton, Alberta, Canada
Status: Offline
Reply With Quote
Nov 2, 1999, 04:29 PM
 
prop: yourIP :""
set yourIP to (get IP address of (network information))
set yourMessage to "Your Current IP address is: " & yourIP

tell application "Outlook Express"
activate
run
make draft window with properties {to recipients:"[email protected]", subject:yourMessage, content: yourMessage }
set theWindow to the front window
send theWindow
end tell

you need the network OSAX avail at :
http://ackmo.baylor.edu/~bellc/files...k_Info_1.0.hqx

Since i dont use OE i dont know if that would work or not, tho the code that i added would work...


[This message has been edited by MacCanada (edited 11-02-1999).]
-- An idea is salvation by imagination.
-- Frank Lloyd Wright
-- 30 --
     
JoshFofer
Junior Member
Join Date: Nov 1999
Location: Los Angeles, CA, USA
Status: Offline
Reply With Quote
Nov 3, 1999, 06:32 AM
 
This is an excellent idea, and I'd like to take it a step further. Rather than requiring Outlook Express, and e-mailing a message to myself everyday, why not use AppleScript on it's own to send an HTML file to an FTP server? This way, I (or any of my clients) can simply check my own specific web page and see what my current IP address is.

The way I understand it, the Network Browser in OS 9 can now act as a full-fledged FTP client. I'd love to get some assistance on writing an AppleScript that automatically determines my IP address, generates a simple text.html file, and then uploads it to a specific FTP directory. I believe this would be the best solution for the situation Scotty described above.

FWIW, a similar functionality is promised by an older utility called "IP Poster Script," available at http://tucows.tsi.com.pe/mac/ipmac.html. ("IP Poster Script is a nice little AppleScript which will post your current IP address to the FTP directory of your choice ... It's great for keeping others up-to-date as to your whereabouts by linking to the file from your personal home page.")

The only issue is that it relies on using two other programs, IP Monitor and Fetch. I would hope that the "network OSAX" that MacCanada mentioned would take care of the IP reporting (instead of using IP Monitor) and that the Network Browser could be used in place of Fetch.

Any assistance in this regard would be appreciated. I am just starting to learn AppleScript, and this is a very useful and interesting exercise from which I can learn.

And while we're on the subject, does anyone have any good suggestions on a good, current beginner's guide book (or web page) to AppleScripting?

Thanks in advance for any and all feedback!



------------------
----
Joshua Rafofsky
User Friendly Technology
     
MacCanada
Junior Member
Join Date: Oct 1999
Location: Edmonton, Alberta, Canada
Status: Offline
Reply With Quote
Nov 3, 1999, 09:10 AM
 
well taking it even one step further and using
URL access scripting ( that comes with OS 8.5, 8.6 & 9):


-- <code>

-- sets this as a property the file spec
property Filename : ((path to application support) & "ip.html" as string)

-- set up your FTP url here, sets this as a propertyfor your FTP server
property FTPURL : "ftp://ftp.foo.com/yourDir/"

-- sets a comment ot the file so you dont forget what the file is for.
tell application "Finder"
set comment of file "ip.html" of folder "Application Support" of folder "System Folder" of startup disk to "AppleScript IP Poster Data File"
end tell


try
-- gets your IP
set yourIP to (get IP address of (network information))

--opens the file for writing
open for access file Filename with write permission

-- resets the file
set eof file Filename to 0

-- writes the HTML to the File
write "<HTML><HEAD><TITLE>Your IP Address: " & yourIP & "</TITLE></HEAD><BODY><CENTER><B>Your IP Address Is:</B><BR><FORM><INPUT VALUE=" & yourIP & "></FORM></CENTER></BODY></HTML>" to file Filename

-- closes the file
close access file Filename


on error errorMessage number errorNumber

-- closes the file if there's an error, we dont want the file left open now do we?
close access Filename

-- displays a dialog telling you what the error was
beep
display dialog errorMessage & return & errorNumber
end try

-- URL Access Scripting is in your scripting aditins folder, default install w/ AppleScript.
tell application "URL Access Scripting"
try

-- add a key to the keychain in os ( it will be faster (presumming of course your chain is unlocked)
upload Filename to FTPURL with authentication

-- quits the app as it's a background app
quit

on error errorMessage number errorNumber
-- displays a dialog telling you what the error was
beep
display dialog errorMessage & return & errorNumber

-- quits the app as it's a background app
quit
end try
end tell

-- if you modify this code please Give me credit for the original code, thx.

-- </code>

all you need to do is change the property FTPURL to reflect your own ftp server

i also have one so you can mail direct from applescript i will post that
one as soon as it's tested with OS 9

Stay tuned...



[This message has been edited by MacCanada (edited 11-03-1999).]
-- An idea is salvation by imagination.
-- Frank Lloyd Wright
-- 30 --
     
MacCanada
Junior Member
Join Date: Oct 1999
Location: Edmonton, Alberta, Canada
Status: Offline
Reply With Quote
Nov 3, 1999, 09:34 AM
 
Here's the AppleScript Mailer:


--<code>

-- set this to your email address you want this to send to
property to_ : "[email protected]"

-- set this to your mail server name
property yourMailServer : "mail.yourEmailProvider.com"

-- gets your IP
set yourIP to (get IP address of (network information))

-- sends the email
(send email "From: AppleScript IP Address Mailer " & return & �
"To: " & to_ & return & �
"Subject: Your IP address is: " & yourIP & return & �
"X-Mailer: AppleScript" & return & �
"X-URL: <A HREF="http://www.apple.com/applescript"" TARGET=_blank>http://www.apple.com/applescript"</A> & return & �
"Content-Type: text/plain; charset=us-ascii" & return & �
"Your IP is: " & yourIP via yourMailServer)

-- if you modify this code please Give me credit for the original code, thx.
-- &lt;/code&gt;

this requires the Sendmail -t OSAX; http://www.lilback.com/software/#SendmailOSAX


also, you could blend both scripts together, or what about having it page your PCS phone?... and idea, no?...

cheers
-- An idea is salvation by imagination.
-- Frank Lloyd Wright
-- 30 --
     
scotty321  (op)
Fresh-Faced Recruit
Join Date: Nov 1999
Location: Chicago, IL USA
Status: Offline
Reply With Quote
Nov 3, 1999, 12:48 PM
 
Wow! Thanks for all the responses, especially MacCanada for your incredible AppleScripting help!!!

However, because I'm a total AppleScript beginner, the line that says:
"set yourIP to (get IP address of (network information))"
throws me off. I'm not sure HOW to go about "getting the IP address of (network information)" within an AppleScript. There seems to be no way to poll the Mac OS and figure out what the current IP address is via AppleScript, but I could be wrong. I've opened up the Script Dictionary for almost every part of the system folder, but I can't find any reference to an IP address.

Any help would be greatly appreciated!!

Thanks again, MacCanada and JoshFofer! You guys are the greatest!

Long live the Mac!

See ya,
Scott

--
Scott Rose, President
Scott's Software Solutions
Your FileMaker Pro Experts Since 1992

(323) 954-1978
(253) 736-7627 fax http://www.scottworld.com
     
JoshFofer
Junior Member
Join Date: Nov 1999
Location: Los Angeles, CA, USA
Status: Offline
Reply With Quote
Nov 3, 1999, 03:59 PM
 
I'm inspired. Thanks MacCanada for such great info. I've done some searching around and found that the actual link for the Network Info OSAX is: http://ackmo.baylor.edu/~bellc/files...o_OSAX_1.2.hqx

(The other one listed, "Network Info," is merely an app which reports similar info.)

With this OSAX installed, I believe we can follow MacCanada's previously mentioned AppleScript commands:

prop: yourIP :""
set yourIP to (get IP address of (network information))

Then again, I'm not sure, as perhaps this same command is possible via the URL Access Scripting in 8.x and beyond.

Hope this helps. I'm going to try it out myself ASAP.

[This message has been edited by JoshFofer (edited 11-03-1999).]
     
scotty321  (op)
Fresh-Faced Recruit
Join Date: Nov 1999
Location: Chicago, IL USA
Status: Offline
Reply With Quote
Nov 3, 1999, 04:28 PM
 
Thanks again, JoshFofer, for the very useful information!

However, the AppleScript seems to yield an error when getting to the "Send email" script step.

Hmmm... still trying to figure it out over here....

------------------
--
Scott Rose, President
Scott's Software Solutions
Your FileMaker Pro Experts Since 1992

(323) 954-1978
(253) 736-7627 fax
http://www.scottworld.com
     
MacCanada
Junior Member
Join Date: Oct 1999
Location: Edmonton, Alberta, Canada
Status: Offline
Reply With Quote
Nov 3, 1999, 08:05 PM
 
&gt;However, the AppleScript seems to yield an error
&gt;when getting to the "Send email" script step.

What's the error that's reported?

&gt;Hmmm... still trying to figure it out over here....

a few things, did you install the two OSAXes (scripting aditions)?
network infor and send mail -t OSAX (just drop them on your closed system folder, they will be placed automatically

also you'll ned to change a few things in the script such as

property to_ : "[email protected]"
property yourMailServer : "mail.yourEmailProvider.com"

where you need to change the values
"[email protected]" and "mail.yourEmailProvider.com"
to reflect your email and mail server...

when you use the script editor besure to open the event log window (cmd E)
and the result window (cmd L) also it's helpful to to check both check boxes in the event log window named "Show Events" and "Show Event Results"

hope that helps....



[This message has been edited by MacCanada (edited 11-03-1999).]
-- An idea is salvation by imagination.
-- Frank Lloyd Wright
-- 30 --
     
MacCanada
Junior Member
Join Date: Oct 1999
Location: Edmonton, Alberta, Canada
Status: Offline
Reply With Quote
Nov 3, 1999, 08:22 PM
 
&gt;However, because I'm a total AppleScript beginner, the line that says:
&gt;"set yourIP to (get IP address of (network information))" throws me off.
&gt;I'm not sure HOW to go about "getting the IP address of (network information)"
&gt;within an AppleScript.

how about we deconstruct that line:
set x to y -- set x to what ever the result is from y

set yourIP to "123.456.789.000" would set yourIP to "123.456.789.000"


as with math anything in a parentheses is evaluated first.so what ever
is the most nested item gets evaluated first, in this case that's netwrk info.:


(network information)

we call network info here first which returns a bunch of info


(get IP address of (network information))

we dont need all the info returned so we ask
for the ip address in the info returned.

set yourIP to (get IP address of (network information))

then we store that result in a variable "yourIP"

in a more simpler dialog would be:

you: what is my ip adddress?
mac: 127.0.0.1
you: put that address in a place called yourIP
mac: ok, yourIP now contains "127.0.0.1"


if you want, i can email ya and we could talk about
this (or more applescript inquires) in more detail.



[This message has been edited by MacCanada (edited 11-03-1999).]
-- An idea is salvation by imagination.
-- Frank Lloyd Wright
-- 30 --
     
scotty321  (op)
Fresh-Faced Recruit
Join Date: Nov 1999
Location: Chicago, IL USA
Status: Offline
Reply With Quote
Nov 5, 1999, 01:48 PM
 
MacCanada,

You are a true AppleScripting genius! I haven't tested out your AppleScript yet, but you have inspired me to tackle other AppleScripts in the world!

I was wondering if you know any great resource where I can learn about AppleScripting? I heard that the book "Danny Goodman's AppleScript Handbook" is fairly good.

In the meantime, I've been having a minor problem with scripting QuickMail Pro 2.0.4 for Macintosh, but the folks at CE Software say that they do not offer technical support with AppleScripting their product. I'm soooo close to making it happen, but it just isn't working.

Totally random question, but do you happen to know anything about scripting QuickMail Pro??

(If you do, please read on. If not, thanks for everything!)

It seems to me, even though I'm a novice AppleScript user, that there's a bug in QuickMail Pro. I've got a simple AppleScript that says:

tell application "QuickMail Pro"
New Message
Set Message "Subject Here"
Set Message Body "Body Here"
Set Message Recipients Address "[email protected]"
Send Message
end tell

All the steps work, except the line that starts with "Set Message Recipients Address", which ends up putting 2 blank lines in the addressing area, and THEN puts the address in between those 2 lines... I think it could be a bug in QuickMail. I'm not sure.

Thanks again for everything, Mac Canada!

See ya,
Scott

------------------
--
Scott Rose, President
Scott's Software Solutions
Your FileMaker Pro Experts Since 1992

(323) 954-1978
(253) 736-7627 fax http://www.scottworld.com

[This message has been edited by MacCanada (edited 11-05-1999).]
     
MacCanada
Junior Member
Join Date: Oct 1999
Location: Edmonton, Alberta, Canada
Status: Offline
Reply With Quote
Nov 5, 1999, 09:33 PM
 
&gt;Totally random question, but do you happen to know anything
&gt;about scripting QuickMail Pro??

no, but if you email me a screen shot of the applications dictonary,
i would be more than happy to see what i can do.



------------------
---
PGP key: http://www.geocities.com/maccanada/pgpkey.html
-30-
-- An idea is salvation by imagination.
-- Frank Lloyd Wright
-- 30 --
     
   
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
Top
Privacy Policy
All times are GMT -4. The time now is 01:51 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,