<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>hi, it&#39;s mike</title>
    <link>https://mike.puddingtime.org/tags/transmit/</link>
    <description>Recent content on hi, it&#39;s mike</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <managingEditor>mike@puddingtime.org (mike)</managingEditor>
    <webMaster>mike@puddingtime.org (mike)</webMaster>
    <copyright>© 2026, mike</copyright>
    <lastBuildDate>Wed, 28 Apr 2010 02:47:55 +0000</lastBuildDate>
    <atom:link href="https://mike.puddingtime.org/tags/transmit/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>New Transmit - Use It With rb-appscript</title>
      <link>https://mike.puddingtime.org/posts/2010-04-28-new-transmit-use-it-with-rb-appscript/</link>
      <pubDate>Wed, 28 Apr 2010 02:47:55 +0000</pubDate><author>mike@puddingtime.org (mike)</author>
      <guid>https://mike.puddingtime.org/posts/2010-04-28-new-transmit-use-it-with-rb-appscript/</guid>
      
      <description>Hey … there’s a new version of Transmit out. They added some neat stuff (like being able to mount remote volumes on your Desktop) and changed the AppleScript dictionary a little.
I use Transmit and appscript to update a pair of files on an ftp server each day. I used to use Ruby’s built-in ftp …</description>
      <content:encoded><![CDATA[<p>Hey &hellip; there&rsquo;s a <a href="http://www.panic.com/blog/2010/04/transmit-4-0/">new version of Transmit</a> out.  They added some neat stuff (like being able to mount remote volumes on your Desktop) and changed the AppleScript dictionary a little.</p>
<p>I use Transmit and appscript to update a pair of files on an ftp server each day.  I used to use Ruby&rsquo;s built-in ftp library, but I ran into a few cases where I&rsquo;d make a mistake during editing and only realize it  once I&rsquo;d uploaded the files. It was helpful to have a regular ftp app open so I could go back and make quick corrections.</p>
<p>As always, <a href="http://appscript.sourceforge.net/tools.html">AS Translate</a> is really handy.  You can use it to paste native AppleScript into a window and get a translation to rb-appscript. That makes translating Panic&rsquo;s sample AppleScript into usable Ruby a five minute process.</p>
<p>I use <a href="http://www.chungwasoft.com/Shimo/">Shimo</a> to manage my VPN connection, so my script checks to see if Shimo is active and connected. This is a little crude, because I only have one VPN connection to worry about, so I don&rsquo;t check to make sure it&rsquo;s the right one:</p>
<pre><code>require &quot;rubygems&quot;

require &quot;appscript&quot;

include Appscript

transmit = app(&quot;Transmit&quot;)

shimo = app(&quot;Shimo&quot;)

status = shimo.controller.connected.get

unless status == true

	puts &quot;Connecting with VPN ...&quot;

	shimo.connect(:with_profile =&gt; &quot;colo&quot;)

	was_up = false

else

	puts &quot;Already connected to the VPN ...&quot;

	was_up = true

end
</code></pre>
<p>Then I set up a few variables. One of the files I edit (news_index) is named based on the month:</p>
<pre><code>host = &quot;remotenewshost.com&quot;

user = &quot;username&quot;

pass = &quot;password&quot;

path = &quot;/news/articles/&quot;

latest_news = &quot;latest_news.html&quot;

news_index = Date.today.strftime(&quot;news_%m_%y.htm&quot;)

transmit.make(:new =&gt; :document)

doc = transmit.documents[0]

doc.current_tab.connect(:to_address =&gt; host,

	:with_password =&gt; pass,

	:as_user =&gt; user,

	:with_initial_path =&gt; path)
</code></pre>
<p>Then I download the files I need. If it&rsquo;s early in the month, one of them might not exist on the remote server, so I pull a copy of a template I store locally. There are native Ruby commands to move files around, but I just don&rsquo;t bother.</p>
<pre><code>doc.current_tab.remote_browser.download(

	:with_resume_mode =&gt; :overwrite, 

	:to =&gt; &quot;~/	Desktop&quot;, 

	:item_at_path =&gt; &quot;{path}{latest_news}&quot;)

list = doc.current_tab.remote_browser.browser_items.name.get

if list.include?(news_index)

	puts &quot;Found monthly index, downloading ...&quot;

	doc.current_tab.remote_browser.download(

		:with_resume_mode =&gt; :overwrite, 

		:to =&gt; &quot;~/Desktop&quot;, 

		:item_at_path =&gt; &quot;{path}{news_index}&quot;)

else

  puts &quot;Didn't find monthly index, copying from a template ...&quot;

  `cp /Users/mike/Documents/Application\ Data/pracnet_news_index_skel.htm\

	 /Users/mike/Desktop/{latest_news}`

end
</code></pre>
<p>Then I open the files in my text editor, TextMate:</p>
<pre><code>`mate -w /Users/mike/Desktop/{latest_news}`

`mate  -l 25 -w /Users/mike/Desktop/{news_index}`
</code></pre>
<p>The &ldquo;-l 25&rdquo; tells TextMate to place the cursor at line 25 of the file, which is after all the header junk. It saves me cursoring to where I need to go.</p>
<p>Then I squirt the files back up:</p>
<pre><code>puts &quot;Uploading latest news file ...&quot;

doc.current_tab.remote_browser.upload(:with_resume_mode =&gt; :overwrite, :to =&gt; \

path, :item_at_path =&gt; &quot;~/Desktop/{latest_news}&quot;)

puts &quot;Uploading monthly news file ...&quot;

doc.current_tab.remote_browser.upload(:with_resume_mode =&gt; :overwrite, :to =&gt;\

path, :item_at_path =&gt; &quot;~/Desktop/{news_index}&quot;)
</code></pre>
<p>and check to see what the status of the VPN connection was when I started the script to determine whether to keep it open or bring it down:</p>
<pre><code>if was_up == false

  puts &quot;Shutting down VPN connection ...&quot;

  shimo.disconnect

else

  puts &quot;VPN connection was up at launch ... keeping it up and ending.&quot;

end
</code></pre>
<p>Know what&rsquo;s awful?  My employer won&rsquo;t allow me to connect this way for much longer. Some time in the next 30 days, I&rsquo;ll be forced to do all this from a Windows machine. No more Transmit, no more rb-appscript. I can dig out the code I wrote that uses the standard Ruby ftp library, but it won&rsquo;t be as handy.</p>
<p>Rats.</p>
<p>#appscript #ruby #shimo #transmit</p>
<p><em><a href="mailto:mike@puddingtime.org?subject=Re%3A%20New%20Transmit%20-%20Use%20It%20With%20rb-appscript">Drop a line about this</a>.</em></p>]]></content:encoded>
    </item>
  </channel>
</rss>
