<div id="popup_box_thanks" style="display:none" onClick="close_popup_thanks('popup_box_thanks', 'ts')"><br>Thanks for submitting your tip! All submissions are moderated by an editor before appearing online. We've reset the form so you can enter another tip. Or you can close the tip submission box. <div class="x_close" id="thanks_upper_right"><a href="javascript:void(0)" onmousedown="close_popup_thanks('popup_box_thanks', 'ts'); return true;">Close</a></div></div>
<div class="tbf_row"><div class="tbf_wide_extra_top not_bold">Please submit only technical tips that will help other TidBITS readers better use their Macs, iPhones, and related software and hardware. All product announcements should be sent to <a href="mailto:releases@tidbits.com">releases@tidbits.com</a>.</div></div>
<div class="tbf_left">URL</div><div class="tbf_right"><input type="text" value="" name="tip_link_url" tabindex="3"><span class="tip_description"><br>Enter the URL to a Web page that supports your tip.</span></div>
</div>
<div class="spacer"></div>
<div class="tbf_row">
<div class="tbf_left">Linked text</div><div class="tbf_right"><input type="text" value="" name="tip_link_label" tabindex="4"><span class="tip_description"><br>Enter the name of the page linked above.</span></div>
<div class="tbf_wide"><input type="submit" value="Preview Your Tip" name="preview_tip" onClick="fill_preview('tipbits_enclosure_preview', 'ts', this.form); return false;" tabindex="7"> <input type="submit" value="Send Us Your Tip!" name="submit_this_tip" onClick="handle_tip_submission('ts', '', this.form, 'tip'); return false;" tabindex="8"></div>
</div>
<div class="spacer"></div>
<div class="tbf_row">
<div class="tbf_wide"><span class="fine_print">When you submit a tip, you give us permission to use it. Read <a href="javascript:void(0)" onClick="generic_show_hide('tip_terms')">our terms</a> for more details. All submissions are reviewed before publication.</span></div>
<div class="tbf_wide"><span class="fine_print">Our terms: By submitting a tip, you agree to assign TidBITS Publishing Inc., a non-exclusive, worldwide, perpetual license to reproduce, publish, and distribute your tip in connection with the TidBITS Web site and associated products in any media. You agree that you created the content you submitted, and that you have the right to assign us this license. You give us permission to use your name, but your email address won't be publicly displayed or shared. We review all submissions before publication, and reserve the right to select which submissions we feel are appropriate for our readers and to edit those we publish.</span></div>
<div id="comment_thanks" style="display:none" onClick="close_popup_thanks('comment_thanks', 'comm')"><br>Thanks for submitting a comment! Please check your email for a link that, when clicked, will verify that you're a real person and cause your comment to appear immediately. <div class="x_close" id="comment_upper_right"><a href="javascript:void(0)" onmousedown="close_popup_thanks('comment_thanks', 'comm'); return true;">Close</a></div></div>
<div class="tbf_wide"><span class="fine_print">Our terms: We reserve the right to edit or delete any comment, so please post thoughtfully. We use your email address <i>only</i> to send you a one-time verification message confirming that you posted this comment. We also store your address to allow you to verify using other Web browsers in the future. For more info, see our <a href="http://db.tidbits.com/privacy.html">privacy policy</a>.</span></div>
<li><a href="/feeds/tidbits.rss" title="Subscribe via RSS" class="gettb">RSS <img src="/images/feed-icon-12x12.gif" width="12" height="12" border="0" class="nav_img" alt="Subscribe via RSS"></a></li>
<li><a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=276986548" title="Subscribe to the podcast" class="gettb">Podcast <img src="/images/feed-icon-12x12_podcast.gif" width="12" height="12" border="0" class="nav_img" alt="Subscribe to the postcast"></a></li>
<li><a href="http://www.twitter.com/TidBITS" title="Get Article Updates via Twitter" class="gettb">Twitter <img src="/images/feed_icon_12x12_twitter.png" width="12" height="12" border="0" class="nav_img" alt="Get Article Updates via Twitter"></a></li>
<li><a href="http://www.facebook.com/pages/TidBITS/195314925519" title="Go to the TidBITS Page at Facebook" class="gettb">Facebook <img src="/images/feed_icon_12x12_facebook.gif" width="12" height="12" border="0" class="nav_img" alt="Go to the TidBITS Page at Facebook"></a></li>
<li><a href="javascript:void(0)" title="Sections" class="tabhead" onClick="return showhide('articleslist')">Sections <span id="articleslist_triangle"><img src="/images/nav_triangle_open.gif" width="9" height="9" border="0" class="navtriangle" id="articleslist_tri_image" alt="Click to show or hide the contents of this section."></span></a></li>
<li><a href="javascript:void(0)" onClick="return showhide('stafflist')" title="Staff" class="tabhead">Staff <span id="stafflist_triangle"><img src="/images/nav_triangle_closed.gif" width="9" height="9" border="0" class="navtriangle" id="stafflist_tri_image" alt="Click to show or hide the contents of this section."></span></a></li>
<li><a href="javascript:void(0)" title="Issues" class="tabhead" onClick="return showhide('issuelist')">Weekly Issues <span id="issuelist_triangle"><img src="/images/nav_triangle_closed.gif" width="9" height="9" border="0" class="navtriangle" id="issuelist_tri_image" alt="Click to show or hide the contents of this section."></span></a></li>
<li><a href="javascript:void(0)" onClick="return showhide('abouttidbits')" title="About TidBITS" class="tabhead">About TidBITS <span id="abouttidbits_triangle"><img src="/images/nav_triangle_closed.gif" width="9" height="9" border="0" class="navtriangle" id="abouttidbits_tri_image" alt="Click to show or hide the contents of this section."></span></a></li>
<div class="center_top">Thoughtful, detailed coverage of the Mac, iPhone, and iPad, plus the best-selling <a href="http://www.takecontrolbooks.com/?pt=TB-TAGLINE" style="color:yellow">Take Control</a> ebooks.</div>
<!-- begin centercolumn -->
<div id="centercolumn">
<!-- begin rightcolumn_container -->
<div id="rightcolumn_container">
<!-- begin rightcolumn -->
<!-- rightcolumn is embedded within centercolumn so featured text wraps around it -->
</div><!-- end tearoffbox_wide_container for watchlist items -->
<!-- begin tearoff box wide -->
<div class="tearoffbox_wide_container">
<div class="tearoffbox_wide_tips">
<div class="tip_display">
<div class="tips_sponsor_logo">
</div>
<h6>Just Show Me the Pictures!</h6>
<p><p>Do you ever find that you don't have time to read those long email missives from Aunt Carol, but really do want to see the photos that she has lovingly attached? In Apple Mail, click the Quick Look button located in the message header. You'll get an easily browsed view of just the attached photos, and you can even add them to iPhoto, if you like!</p></p>
</div>
<div class="tearoffbox_wide_bottom_tips">
<div style="padding-bottom:35px"><div class="tip_display" style="float:left"><p><br><a href="/tipbits/154">Link to this tip</a></p></div><div class="tip_display" style="float:right; width:150px">
<div class="tbf_wide_80" id="hc_rc_4073">To help us avoid automated posts and misuse of our site, please enter the words below.</div><div class="x_close_row" id="hc_upper_right2_4073"><a href="javascript:void(0)" onmousedown="HidePopupContent('hc_4073', 'hc', '4073'); return true;">Close</a></div>
<div class="featured_meta"><div class="meta_article">17 May 1999 | <a href="/article/5396?print_version=1">Print <span class="shift_up"><img src="/images/printer_icon.gif" alt="Printer-Friendly Version of This Article" border="0" width="9" height="10"></span></a></div></div>
<div id="article_box_4073"><P>Last week in <A HREF="http://www.tidbits.com/tb-issues/TidBITS-480.html">TidBITS-480</A>, I looked at new capabilities in Mac OS 8.6; this week, I'd like to focus on one new feature I think deserves special attention: URL Access.</P><P><<A HREF="http://db.tidbits.com/article/05387">http://db.tidbits.com/article/05387</A>></P><P><STRONG>Low-Level Power</STRONG> -- URL Access is a new system component that enables programs to transfer information to and from the Internet using HTTP or FTP. Around the time Apple introduced Game Sprockets in 1996, several Macintosh Internet developers pushed the idea of "Apple Internet Sprockets" which would give any application basic Internet connectivity. Why is this idea interesting? Before URL Access, any program wanting to access the Internet had to write its own protocol handlers to interact with Web servers, upload to FTP sites, and whatnot, so every developer re-invented the wheel for every Internet application or utility. Wouldn't it be great if the Mac OS could provide basic Internet functions to any program that wanted them? The project came to life under the codename SubWoofer but was shelved by Apple in the sweeping re-organizations of 1996 and 1997. SubWoofer was adopted by Leonard Rosenthol and other developers, and this year Apple finally decided to roll it into the Mac OS itself.</P><P>URL Access provides applications with the capability to upload and download information using HTTP (optionally using 40-bit RSA encryption) and FTP, to access local files using the "file://" URL scheme, to gather various data about URLs, and more. URL Access doesn't provide all the capabilities needed by a high-end Web browser - especially ones that need to run on versions of the Mac OS prior to 8.6 - but it's a perfect platform for Internet utilities and custom applications. For instance, Sherlock 2.1 now does all its Internet communication through URL Access. Over time, you can expect more Internet tools to use URL Access to communicate with the Internet, rather than writing their own protocol handlers.</P><P><STRONG>Scriptability</STRONG> -- Apple took URL Access one step further by making it accessible to AppleScript and other OSA scripting environments, like UserLand Frontier.</P><P><<A HREF="http://db.tidbits.com/article/05351">http://db.tidbits.com/article/05351</A>></P><P>The Mac OS 8.6 Scripting Additions folder contains a tiny application called URL Access Scripting, which enables any OSA script to transfer data to and from the Internet. This simple AppleScript script downloads the TidBITS home page to a file you specify.</P><PRE> set newFile to (new file) tell application "URL Access Scripting" activate download "http://www.tidbits.com/" to newFile with progress quit end tell</PRE><P>This script (which works only under Mac OS 8.6) prompts you to create a new file, then displays a progress dialog as URL Access Scripting connects to our Web server, downloads the page, and saves it to the file you specified.</P><P>URL Access Scripting's interface is rough around the edges: it was originally intended to be a background-only application with no windows, dialogs, or menus, so Apple didn't give URL Access Scripting any menus - or even a Quit command. However, URL Access Scripting needs to display interface elements like progress and authentication dialogs, so Apple lets it run in the foreground but didn't provide a proper menubar, which can confuse both users and scripters. Remember that your scripts must tell URL Access Scripting to quit when they're finished.</P><P><STRONG>Folder Actions</STRONG> -- URL Access Scripting offers many capabilities - decoding files, posting form data, handling authentication - and opens up new possibilities for integrating AppleScript into your workflow. Here's an example of an AppleScript script you can attach to a folder as a Folder Action. Whenever you drop items into the folder, URL Access automatically uploads them to the FTP directory you specify in the second line of the script, replacing any files with the same names. (Remember that Folder Actions trigger when the visible contents of a folder change, so be sure your FTP folder is open, or attached to the bottom of your screen as a pop-up window.)</P><PRE> on adding folder items to thisFolder after receiving fileList set ftpURL to "ftp://ftp.example.com/YourDirectory/" repeat with i in fileList tell application "Finder" to set thisFileType to the file type of i try tell application "URL Access Scripting" activate if thisFileType is "TEXT" then upload i to ftpURL replacing yes with progress and authentication else -- delete the return between "binhexing" and "and" in the next line upload i to ftpURL replacing yes with progress, binhexing and authentication end if end tell on error errMsg number errNum display dialog (errNum as string) & ": " & errMsg end try end repeat tell application "URL Access Scripting" to quit end adding folder items to</PRE><P>You'll notice this script will binhex non-text files it uploads to an FTP site (taking advantage of another of URL Access's built-in features), but there are plenty of ways to add more intelligence. For instance, if you drop multiple files into this FTP folder, you'll be prompted for a username and password for each file. You could integrate your username and password into the script directly by using a URL in the following form, although it's not a secure solution:</P><P><<A HREF="ftp://username:password@ftp.example.com/YourDirectory/">ftp://username:password@ftp.example.com/ YourDirectory/</A>></P><P>A better idea would be to have the script prompt once for the appropriate name and password, then build an appropriate URL for URL Access Scripting. Similarly, this script could be expanded to handle folders dropped into your FTP folder, to test for the presence of a resource fork to determine whether binhexing is necessary, and to offer error handling in case a problem occurs. You could also add a "removing folder items" script to delete items from the FTP site when they're removed from the folder.</P><P><STRONG>Even More Elaborate</STRONG> -- An important thing to notice with all the possible elaborations on the script above is that the enhancements don't involve URL Access. Taking advantage of URL Access Scripting would still only require a few lines of code, although the rest of the script would become larger to offer more features, flexibility, and intelligence.</P><P>Since getting online stock quotes is commonly bandied about as an example of customized Internet functionality, I've thrown together an AppleScript script using URL Access Scripting that pulls stock prices from Yahoo's finance site. Just type a ticker symbol, and the script sends the appropriate query, grabs the resulting HTML, parses it, and displays a dialog with the pricing information.</P><P><<A HREF="http://www.tidbits.com/resources/481/UASYahoo.html">http://www.tidbits.com/resources/481/ UASYahoo.html</A>></P><P>Again, you'll notice handling URL Access Scripting is easy: just one line to grab the appropriate Web page, and another to tell URL Access Scripting to quit. The rest of the script is concerned with getting the ticker symbol from the user (capitalizing it if necessary), creating and destroying a temporary file for the Web page, and parsing the results returned from Yahoo's server. This script could certainly be smarter - for instance, it should handle connection errors and deal with unknown ticker symbols - but, again, those changes don't involve URL Access Scripting, just the intelligence wrapped around it.</P><P>If you want more examples of using URL Access, check out the scripts Apple showed off at this year's World Wide Developer Conference - they set your desktop picture to images from a variety of Web cams around the world.</P><P><<A HREF="http://www.apple.com/applescript/deskcam/deskcam.html">http://www.apple.com/applescript/deskcam/ deskcam.html</A>></P><P><STRONG>Meet a Schedule</STRONG> -- Another way to utilize URL Access Scripting is to have scripts run automatically at pre-selected times. Although AppleScript doesn't have a built-in scheduler, you can use Sophisticated Circuits' iDo Script Scheduler. A demo version is available for free from Apple, both on its own and as part of Mac OS 8.6's AppleScript Extras, which is also on the Mac OS 8.6 CD-ROM. The iDo Script Scheduler enables you set up three scripts that run automatically; the forthcoming full version should handle an unlimited number of scripts and offer additional capabilities. Several other scheduling utilities are available on their own or as parts of other products; I've been using Late Night Software's $25 Scheduler for years, and Unix aficionados should check out Chris Johnson's cron for Macintosh.</P><P><<A HREF="http://www.apple.com/applescript/idosched/ido.html">http://www.apple.com/applescript/idosched/ ido.html</A>><BR><<A HREF="http://asu.info.apple.com/swupdates.nsf/artnum/n11402">http://asu.info.apple.com/swupdates.nsf/artnum/ n11402</A>><BR><<A HREF="http://www.sophisticated.com/products/ido/ido_sched.html">http://www.sophisticated.com/products/ido/ido_ sched.html</A>><BR><<A HREF="http://gargravarr.cc.utexas.edu/cron/cron.html">http://gargravarr.cc.utexas.edu/cron/cron.html</A>><BR><<A HREF="http://www.latenightsw.com/scheduler1.2/index.html">http://www.latenightsw.com/scheduler1.2/ index.html</A>></P><P><STRONG>Script Happy</STRONG> -- At long last, integrating the Internet into your custom scripts and workflow is simple and built directly into the Mac OS. Although URL Access can't do everything that's possible with lower-level TCP/IP scripting tools like Mango Tree Software's TCP/IP Scripting Addition or BIAP's NetEvents, it provides a wide range of common functionality that's easy to use. Even if you don't have much familiarity with AppleScript, a little effort can dramatically improve your use of the Internet.</P><P><<A HREF="http://www.mangotree.com/">http://www.mangotree.com/</A>><BR><<A HREF="http://www.biap.com/products/netevents/">http://www.biap.com/products/netevents/</A>></P><!-- Putting URL Access Scripting to Work Geoff Duncan --></div>
<!-- end article text -->
<!-- PayBITS -->
<p> </p><div class="sponsorbox">
<div class="sponsortext"><A HREF="http://www.econtechnologies.com/tb"><IMG SRC="http://db.tidbits.com/images/badges/chronosync.png" ALT="" HEIGHT="50" WIDTH="50" BORDER="0" ALIGN="left"></A>With ChronoSync you can sync, back up, or make bootable backups.<br />Sync or back up your Mac to internal or external hard drives, other<br />Macs, PCs, or remote network volumes you can mount on your Mac.<br />Learn more at <<a href="http://www.econtechnologies.com/tb.html">http://www.econtechnologies.com/tb.html</a>>!</div>