<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>info.michael-simons.eu &#187; Applescript</title>
	<atom:link href="http://info.michael-simons.eu/tag/applescript/feed/" rel="self" type="application/rss+xml" />
	<link>http://info.michael-simons.eu</link>
	<description>Just another nerd blog</description>
	<lastBuildDate>Fri, 09 Jul 2010 07:40:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Put your mac to rest via ssh</title>
		<link>http://info.michael-simons.eu/2008/07/17/put-your-mac-to-rest-via-ssh/</link>
		<comments>http://info.michael-simons.eu/2008/07/17/put-your-mac-to-rest-via-ssh/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 11:23:52 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[English posts]]></category>
		<category><![CDATA[Applescript]]></category>
		<category><![CDATA[Tipps]]></category>

		<guid isPermaLink="false">http://info.michael-simons.eu/?p=179</guid>
		<description><![CDATA[Sometimes my Macbook decides to wake up from his sleep (a.k.a hibernation). Most of the times i notice this at work when my emails disappear from my imap inbox as Mail.app applies his rules. As i do not have Apple Remote Desktop or any other VNC server enabled on my Macbook, i do have a [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes my Macbook decides to wake up from his sleep (a.k.a hibernation). Most of the times i notice this at work when my emails disappear from my imap inbox as Mail.app applies his rules.</p>
<p>As i do not have Apple Remote Desktop or any other VNC server enabled on my Macbook, i do have a problem.</p>
<p>I can vpn into my home and i can ssh into the Macbook, so i came up with the following solution:</p>
<p>Put the following three lines into a plain textfile, i.e. &#8220;sleep.txt&#8221; and save it somewhere:</p>
<pre>
tell application "Finder"
  sleep
end tell
</pre>
<p>Then, open Terminal.app, change to the directory you saved the file in and execute:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">osascript sleep.txt</pre></div></div>

<p><del>Your ssh connection will then timeout and the Mac sleeps.</del></p>
<p>Stupid me forgot that ssh can execute remote commands: From your workmachine execute</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ssh</span> my_home_computer <span style="color: #ff0000;">'osascript sleep.txt'</span></pre></div></div>

<p>and you&#8217;re done. Thanks &#8220;tante&#8221; for reminding me <img src='http://info.michael-simons.eu/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Alternatively, you can achieve similar with Mail.app itself, have a look at the solution <a href="http://osxdaily.com/2007/02/06/put-your-mac-to-sleep-remotely-via-email-or-text-message/">here</a>, but i like mine better.</p>
<p class="akst_link"><a href="http://info.michael-simons.eu/?p=179&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_179" class="akst_share_link " rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://info.michael-simons.eu/2008/07/17/put-your-mac-to-rest-via-ssh/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Search and replace</title>
		<link>http://info.michael-simons.eu/2006/04/23/search-and-replace/</link>
		<comments>http://info.michael-simons.eu/2006/04/23/search-and-replace/#comments</comments>
		<pubDate>Sun, 23 Apr 2006 08:49:45 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Applescript]]></category>
		<category><![CDATA[Code Snippets]]></category>

		<guid isPermaLink="false">http://www.msimons.info/?p=7</guid>
		<description><![CDATA[In den meisten &#8220;neueren&#8221; und höheren Programmiersprachen gibt es eine Stringmethode, die &#8220;Suchen und ersetzen&#8221; implementiert oder wenigstens Bibliotheken, die so etwas können. Applescript kann das nicht. Um auf Planet-Punk.de meine iTunes Charts ohne LastFM präsentieren zu können, brauchte ich aber genau sowas: on searchAndReplace&#40;s, r, t&#41; set d to text item delimiters set text [...]]]></description>
			<content:encoded><![CDATA[<p>In den meisten &#8220;neueren&#8221; und höheren Programmiersprachen gibt es eine Stringmethode, die &#8220;Suchen und ersetzen&#8221; implementiert oder wenigstens Bibliotheken, die so etwas können.<br />
Applescript kann das nicht. </p>
<p>Um auf <a href="http://www.planet-punk.de/charts.php" rel="external">Planet-Punk.de</a> meine iTunes Charts ohne LastFM präsentieren zu können, brauchte ich aber genau sowas:</p>

<div class="wp_syntax"><div class="code"><pre class="applescript" style="font-family:monospace;"><span style="color: #ff0033; font-weight: bold;">on</span> searchAndReplace<span style="color: #000000;">&#40;</span>s, r, t<span style="color: #000000;">&#41;</span>
	<span style="color: #ff0033; font-weight: bold;">set</span> d <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">text</span> <span style="color: #0066ff;">item</span> <span style="color: #0066ff;">delimiters</span>
	<span style="color: #ff0033; font-weight: bold;">set</span> <span style="color: #0066ff;">text</span> <span style="color: #0066ff;">item</span> <span style="color: #0066ff;">delimiters</span> <span style="color: #ff0033; font-weight: bold;">to</span> s
	<span style="color: #ff0033; font-weight: bold;">set</span> t <span style="color: #ff0033; font-weight: bold;">to</span> t<span style="">'</span>s <span style="color: #0066ff;">text</span> <span style="color: #0066ff;">items</span>
	<span style="color: #ff0033; font-weight: bold;">set</span> <span style="color: #0066ff;">text</span> <span style="color: #0066ff;">item</span> <span style="color: #0066ff;">delimiters</span> <span style="color: #ff0033; font-weight: bold;">to</span> r
	<span style="color: #ff0033; font-weight: bold;">tell</span> t <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033; font-weight: bold;">set</span> t <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #ff0033;">beginning</span> <span style="color: #000000;">&amp;</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#123;</span><span style="color: #009900;">&quot;&quot;</span><span style="color: #000000;">&#125;</span> <span style="color: #000000;">&amp;</span> rest<span style="color: #000000;">&#41;</span>
	<span style="color: #ff0033; font-weight: bold;">set</span> <span style="color: #0066ff;">text</span> <span style="color: #0066ff;">item</span> <span style="color: #0066ff;">delimiters</span> <span style="color: #ff0033; font-weight: bold;">to</span> d
	<span style="color: #ff0033; font-weight: bold;">return</span> t
<span style="color: #ff0033; font-weight: bold;">end</span> searchAndReplace</pre></div></div>

<p>Diese kleine Funktion sucht im Text <em>t</em > nach <em>s</em> und ersetzt jedes Vorkommen durch <em>r</em>.</p>
<p>Zack und schon &#8216;nen Bug im Code Snippet Plugin für WP gefunden&#8230;. Zeile 28 der AppleScript Datei für GeSHi ist falsch:</p>
<p>Statt</p>
<pre>'QUOTEMARKS' => array('"',"'"),</pre>
<p>darf sie nur </p>
<pre>'QUOTEMARKS' => array('"'),</pre>
<p>lauten. Wenn man nicht alles selber macht&#8230;</p>
<p class="akst_link"><a href="http://info.michael-simons.eu/?p=7&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_7" class="akst_share_link " rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://info.michael-simons.eu/2006/04/23/search-and-replace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
