Dread Pirate PJ's House of Hacks and Tricks » open.source http://www.pjtrix.com/blawg Sat, 23 Aug 2014 19:46:15 +0000 en-US hourly 1 https://wordpress.org/?v=4.2.29 iPhone Development on Windows & Linux with open source tools http/blawg/2009/07/21/iphone-development-on-windows-linux-with-open-source-tools/ http/blawg/2009/07/21/iphone-development-on-windows-linux-with-open-source-tools/#comments Tue, 21 Jul 2009 19:10:57 +0000 http/blawg?p=168 Continue reading ]]> Yesterday I presented at OSCON 2009. I spoke about how to use Eclipse and the iPhone-dev team’s GCC cross-compiler to develop for iPhone on Windows & Linux. I also spoke about XMLVM, an open source project that lets you develop in Java for Android and deploy on iPhone or Palm WebOS.

You can download the slides and program examples here.

To get started with open source iPhone development, you can download the open source toolchain for Linux or for Windows/Cygwin.

Note: To use the toolchain, you need to obtain the iPhone OS headers, frameworks and libraries. You can jailbreak your device and extract the frameworks and libraries using SSH, or you can decrypt the firmware and extract the framework and libraries from the decrypted disk image. The binaries you need are /System/Library/Frameworks and /usr/lib .

You can download the headers from the iPhone-dev team’s Subversion repository with svn co http://iphone-dev.googlecode.com/svn/branches/include-1.2-sdk

To use the iPhone-dev team’s headers, you need headers for Mac OS X 10.4 SDK. Then you type this at the command line:

cd /path/to/iphone-dev/svn/branches/include-1.2-sdk
./configure --with-macosx-sdk=/Developer/SDKs/MacOSX10.4u.sdk

sudo bash install-headers.sh

Or you can extract them from the official iPhone SDK. :-)

Once you get the binaries and headers, move them to /usr/local/iphone-sysroot/ . The headers go in /usr/local/iphone-sysroot/usr/include/ , frameworks go in /usr/local/iphone-sysroot/System/Library/Frameworks/ , and libraries in /usr/local/iphone-sysroot/usr/lib/ .

Then to compile and link, set CFLAGS and LDFLAGS like below :

export CFLAGS=-I/usr/local/lib/gcc/arm-apple-darwin9/4.2.1/include \
-isysroot /usr/local/iphone-sysroot

export LDFLAGS=-framework CoreFoundation -framework Foundation \
-framework UIKit -lobjc -bind_at_load -isysroot /usr/local/iphone-sysroot

Then use these compile and linker commands :

/usr/local/bin/arm-apple-darwin9-gcc -c $(CFLAGS) main.c HelloWorld.m

/usr/local/bin/arm-apple-darwin9-gcc $(LDFLAGS) HelloWorld.o main.o \
-o HelloWorld

The easiest way to set this up for each project is in a makefile. Look in the HelloWorld example in the zip file with the slides for an example.

]]>
http/blawg/2009/07/21/iphone-development-on-windows-linux-with-open-source-tools/feed/ 13
Obligatory WordPress upgrade post #10101010 and other rumblings at Chez PJ http/blawg/2008/11/28/obligatory-wordpress-upgrade-post-10101010-and-other-rumblings-at-chez-pj/ http/blawg/2008/11/28/obligatory-wordpress-upgrade-post-10101010-and-other-rumblings-at-chez-pj/#comments Sat, 29 Nov 2008 03:24:53 +0000 http/blawg?p=122 Continue reading ]]> So today I updated WordPress to 2.6.5. And like every other time, it was a cinch, all over and done in less than five minutes. Thanks, WordPress guys!

In other news, I have been geeking out with both the iPhone SDK and the Android SDK, and I believe I have a little something special going here. I hope to have it ready for release, on both platforms, sometime in January. Development continues.

I will need beta testers soon. Any T-Mobile G1 users interested in helping out, you can email me at dreadpiratepj [at] gmail [dot] com

Speaking of Android, I started playing with it now that the source code to the whole thing has been released. I managed to get Android booting on a Palm TX, but it still needs a lot of work. It boots, but it doesn’t do crap once it boots. :-)

I get all the way to the “Press the MENU key to unlock” screen, but none of the keys do anything. Neither does touching the screen. It’s an issue with the Linux kernel drivers and device configuration. It just wasn’t made to run on a Palm TX without proper tweaking of the source. I just don’t know what the proper tweaking is.

I need to look in my bag of loot for a Palm serial cable (I’m sure I have one somewhere) and hopefully I can get a serial console from which to poke around inside Android.

I do have Android running successfully on my Sprint Touch (my parents, my sister and I have a family plan on Sprint.) Credit for that goes to Dr. Martin Johnson in New Zeland. I just use his release on my phone (before you ask, no, his release doesn’t work on the Palm TX. It’s the first thing I tried. :-)

]]>
http/blawg/2008/11/28/obligatory-wordpress-upgrade-post-10101010-and-other-rumblings-at-chez-pj/feed/ 0
Can You Hear The Wind Blow http/blawg/2008/10/24/can-you-hear-the-wind-blow/ http/blawg/2008/10/24/can-you-hear-the-wind-blow/#comments Sat, 25 Oct 2008 00:08:21 +0000 http/blawg?p=97 Continue reading ]]>

Photo by liferfe.

The mobile software market is becoming very exciting, and I’ve been watching with interest. I’ve been learning iPhone development for the last ten months, first with the jailbreak toolchain, and in the last six months with the official SDK. Likewise, I’ve been dabbling with the Android SDK.

Many people have compared the growth of mobile software in the last year to the amazing growth of the early PC era.

One difference from those years, is that mobile software is already mainstream. The “personal computer” took about 20 years to “catch on,” from the introduction of the Apple I in 1977, to the Windows boom of the mid-90s. In contrast, Apple has sold over 10 million iPhones in the last 11 months alone. There are few consumers that aren’t at least aware of the iPhone’s existence. T-Mobile sold about a million Android-powered G1 phones in only one month of pre-sale orders from existing T-Mobile customers. The device can now be ordered online for new and existing accounts, although demand is expected to be very high, causing possible shortages. They claim they can sell another million G1 phones between now and the end of the year.

Another difference is the barrier to entry. Computers cost thousands of dollars in the 1980s, and were not as easy to use and develop for at the beginning. To be a developer back then, you had to be a computer engineer or someone with previous software development experience on mainframes or minicomputers, which at the time was not as widespread knowledge as in these dime-a-dozen-MCSD days. The barrier to entry was very high, economically and educationally. The barrier to entry for iPhone and Android development is very low, with devices available for less than $200 USD. If you already develop software, be it for the web, intranets, or desktops, you already have most of the skills, and a computer with which to develop. So the cost of development tools and training for these platforms is very low, especially for Android. How come it is lower for Android development, you ask?

To develop for the iPhone App Store, you need to already own a Mac with Leopard 10.5.4. So if you don’t have a Mac, that’s an extra expense. With Android, you can use the computer you already have. To put your application on the iPhone App Store, you need to pay $99 USD + tax to Apple and submit your application and say please and cross your eyes and dot your tease (double pun intended, if perhaps lame.) You can sell Android apps from the trunk of your car at a flea market if you want, but to sell them on the Android Market you need to pay $25 USD, although there is no validation or approval process. For either iPhone or Android, you need to buy a device to test on real hardware and make sure things run well.

Of course, you can always develop iPhone software for the iPhone jailbreak community, using the computer you already own, without having to pay anyone a cent, nor having to seek permission. You will still need a device on which to test on, which brings you up to par with Android in terms of barrier to entry. But then you’d be limiting your market to the 20 to 30 % of iPhone users who jailbreak their device. 200,000 – 300,000 and growing is not a bad number of potential users, though. Many of today’s software giants were founded when PC user numbers were much lower.

Anyhow, I digress. My point is that just like I heard the call of the wild and left full-time employment in a Java consulting shop for freelance web work in Rails nearly three years ago, I hear the winds of change and opportunity roaring by. And I want to get my kite out and test the wind.

As you can see, I’ve researched the market. I’m going to cut back on freelance web projects, to start dedicating time to developing a growing stable of ad-supported and for pay mobile apps, for both iPhone and Android. I can bootstrap this effort and support myself for two years on only a small portion of my savings. I believe there is enough growth in the mobile apps market to make back my investment and grow it a little bit. The monetary barrier to entry is so low, the only risk is time and effort lost if things don’t work out. If that happens, I can always go back to what I did before. But I’m not going to forgive myself if I don’t try this.

There will be other related news soon. :-) Meanwhile, enjoy the breeeeezeeeee. Ha ha!

Song “Can You Hear The Wind Blow”, by Whitesnake

]]>
http/blawg/2008/10/24/can-you-hear-the-wind-blow/feed/ 1
Much Railing Lately http/blawg/2007/05/15/much-railing-lately/ http/blawg/2007/05/15/much-railing-lately/#comments Tue, 15 May 2007 05:17:03 +0000 http/blawg/2007/05/15/much-railing-lately/ Continue reading ]]> I’ve been at my new job only four weeks, and my first project is nearly finished. My task these past four weeks has been the re-implementation of the company’s website in Rails. I was to do this from scratch, while keeping the site’s design and existing link structure. Among my requirements is adding support for multiple languages, as the company wants to show it knows how to make websites for a diverse, multi-ethnic audience. Another requirement was, that I was to do this re-implementation by myself. The company only has one other experienced Rails developer, and he is busy doing maintenance work on older non-Rails projects for company customers.

It’s been a pleasure working on this project, and I am very pleased in the progress I’ve made in such a short time. I look forward to going live in another two to three weeks, once the site has been through QA and any changes required.

This coming Wednesday, May 16, I am off to RailsConf 2007, in the lovely city of Portland, Oregon. Portland is great, I have been there twice and I’ve had a great time each trip. I look forward to the visit very much.

Two of my coworkers from the Williams F1 project, Kyle Drake and Nick Wright, are going to be attending RailsConf as well. It’s gonna be great to meet them face-to-face. Daniel Browning, one of my fellow coworkers at my new job, lives just north of Portland. My college buddy Ken Williams lives in the Portland area too. I plan to meet with them at some time during this, my third visit to Portland.

There are so many sessions I want to attend at RailsConf. But interestingly enough, I feel I won’t get any value out of the tutorial sessions, so I didn’t sign up for any of them. That means I’m out of the tutorial-attending n00b league, yeah! :-) We’ll see whether I can hang on to that thought in the other, more advanced sessions. 😀

A few of the sessions sound downright dull. I guess some of the n00bs will find them interesting, since they’re looking for ‘insight’ and whatnot. Whatever. 😉

What am I looking for from RailsConf? I’m looking for some nitty-gritty I can sink my teeth into, some new tech I can experiment with and learn more from. I’m looking forward to have my brain blown by something cool but complicated that I can learn over the next few months. I want to learn about some new-to-me techniques and plugins or gems that I can master and take my Ruby and Rails to a higher level.

I also look forward to meeting some people face to face. Tim Bray is going to be delivering the keynote on Saturday morning. If you’ve been reading my blog for the last year, you already know what I think of him: he’s the d00d!

The JRuby guys will be presenting one session, and I think their work is of importance for the growth of Rails outside the leading edge. I think JRuby will be the thing to help Rails cross the chasm and be adopted by mainstream.

At OSCON 2005, DHH signed my Agile Web Development With Rails 1st Edition, so I will try to get Robert Martin, Dave Thomas, and Andy Hunt to sign some of my other books that they wrote.

Anyway, I’ll talk to you all later!

Technorati Tags:
, , , , , ,

]]>
http/blawg/2007/05/15/much-railing-lately/feed/ 0
Bringin’ in da dough, baby! http/blawg/2007/02/20/bringin-in-da-dough-baby/ http/blawg/2007/02/20/bringin-in-da-dough-baby/#comments Tue, 20 Feb 2007 06:55:10 +0000 http/blawg/2007/02/20/bringin-in-da-dough-baby/ Continue reading ]]> Last Wednesday, I sent emails and résumés for various job posts, and by that afternoon, I started getting nibbles. It was weird! Whereas I barely got any attention for over a dozen job applications I sent out between September and early February, I suddenly had five companies interested in me in a matter of hours! Maybe companies were waiting for post-holiday economy reports to start hiring? I wonder.

So to cut to the chase, I got a great hourly-pay remote development gig working on a Ruby on Rails project, on a really cool sounding website, for a very-high-profile vehicle racing company in the UK. It’s right down Ken’s alley, but if I’m not mistaken, this sport usually has a definitely more European racing audience. I think American racing fans like Ken, might resent these are not American cars, and just don’t watch. LOL

I cannot disclose any more information because of client confidentiality, but I think I may already have said too much. :-p

I’ll post a link here when the site goes up, at any rate. Only then can we drop all this silly NDA crap. It’s a bummer, because I can’t discuss application architecture specifics that would be of interest to my readers.

But fret not. There’s no rule about my discussing the project’s architecture in general. I just can’t say right out what architecture I’m dealing with on this gig.

I’ll be writing more about Rails in the weeks ahead, but just cuz I write about it, don’t mean it’s got a thing to do with work, you hear? :: rolls eyes ::

Technorati Tags:
, , , , , , , , ,

]]>
http/blawg/2007/02/20/bringin-in-da-dough-baby/feed/ 1
Continuing the conversation: PS3 Linux & MS XNA http/blawg/2007/01/23/continuing-the-conversation-ps3-linux-ms-xna/ http/blawg/2007/01/23/continuing-the-conversation-ps3-linux-ms-xna/#comments Tue, 23 Jan 2007 18:56:49 +0000 http/blawg/2007/01/23/continuing-the-conversation-ps3-linux-ms-xna/ Continue reading ]]> Mateusz, Lenny, thanks for the comments.

Update: Reader Mateusz points out that there is an effort under way to port the XNA frameworks to other platforms using Mono. It’s great to see what the subversive, creative types come up with all on their own. It would be hilarious if PS3 owners could run XNA games by simply booting Linux. Take that, Redmond! Welcome to our social. LMAO!

My own take is that Sony is taking a laissez-faire approach, a la Franklin D. Roosevelt and the economy: let’s provide the tools, and whatever happens, happens. Let the market take it where it may. (I hope I am not embarrassing Mrs. Freite, my history teacher in high school, by mixing my economic strategies and presidents.)

While that is great, I think they could be a bit more proactive. They could encourage garage game development with the PS3 Linux project, by marketing it as such. A program like the old PSX Net Yaroze, but with PS3s and Linux, could attract some great talent. (See? Sony has been thinking about this garage developer thing for quite a long time.)

IBM and Toshiba see this as another marketing venue for the Power processor line, especially the work on the Cell Engine that they did. Toshiba only promotes Cell within its embedded processor market, not putting an oar in to help with the garage developer thing. IBM is a bit more active, but only within their established promotional circles: developerWorks and alphaWorks. And it is hardly a big push.

Microsoft is, of course, going all out, promoting XNA as a garage developer’s haven, especially generating excitement with the possibility of garage developers selling games on XBox Live Marketplace for both PC and XBox360. In my opinion, MS is doing a better job at pushing their ideas.

It’s like IBM and Sony don’t quite see what it is they have to do, having just provided the tools and sitting back to see what develops. While it’s great they’re not stirring the pot too much, the stew is gonna ruin if there’s no cook minding the stove.

OK, that’s enough analogies for today. Thanks for keeping the conversation going, guys. Comment away, and let’s keep talking. Anyone else have any thoughts to share?

Technorati Tags:
, , , , , , , , , ,

]]>
http/blawg/2007/01/23/continuing-the-conversation-ps3-linux-ms-xna/feed/ 4
What’s the deal with PS3 Linux? Simple: XNA http/blawg/2007/01/22/whats-the-deal-with-ps3-linux-simple-xna/ http/blawg/2007/01/22/whats-the-deal-with-ps3-linux-simple-xna/#comments Mon, 22 Jan 2007 19:34:37 +0000 http/blawg/2007/01/22/whats-the-deal-with-ps3-linux-simple-xna/ Continue reading ]]> Programming high-performance applications on the Cell BE processor, Part 1: An introduction to Linux on the PlayStation 3

The Sony PlayStation 3 (PS3) is the easiest and cheapest way for programmers to get their hands on the new Cell Broadband Engine (Cell BE) processor and take it for a drive. Discover what the fuss is all about, how to install Linux on the PS3, and how to get started developing for the Cell BE processor on the PS3.

Let’s ignore the $600 USD “cheapest” flame bait and concentrate on the business significance of Sony and IBM providing and promoting Linux for the PS3, shall we?

The PS3 is not the first game console officially sanctioned by the manufacturer to run Linux out of the box. For a few years, Sony sold a $99 Linux kit for the PS2, available only through their online store. It was discontinued early last year, and is now only available on eBay.

But why would Sony provide Linux for any of their video game consoles? What do they have to gain? In business, nothing is done “just” for the benefit of the consumer, much less for pure “free as in freedom” idealism. In the end, it all comes down to driving revenue and profits up, which ultimately pleases the shareholders. Cynical, perhaps, but do you really believe a public company as large as Sony does anything if not for the sake of revenue and profits? Any activity that does not somehow help improve those two factors, will not be seen very positively with the shareholders.

But still, what does it mean? How does PS3 Linux translate into revenue and profits for Sony? Let’s examine this some more, in the context of an obscure game console manufacturer with a similar strategy.

In Korea, the GP32 game console may not have run Linux, but the manufacturer provided on its website, a full set of open source programming tools that ran on Windows. Linux and Mac OS X support was added by the GP32 developer community shortly later. This made the GP32 the first off-the-shelf game console where the users were officially encouraged to make games for it. GamePark, the makers of the GP32, followed up nearly four years later with the Linux-powered GP2X, which also had a free, full set of development tools, including most of the source for the device’s implementation of Linux.

The response to the consoles was great, both in its native Korea and around the world. There is a healthy global open source game development community. Code-savvy game geeks from all around the world have taken to the GP32 and GP2X. Instead of dismal failure competing against Nintendo and Sony, GamePark has survived and grown against all odds. The gadget-happy Koreans responded despite fierce competition, and a healthy Korean commercial game developer community has grown to serve the Korean GP32 market. Many of these commercial developers were founded by the proverbial “two guys in a garage,” propelled to creativity by the open community GamePark fostered.

So back to the PS3. Sure, it’s freakishly expensive for just a single threaded, single tasking, web browser, digital photo gallery, photo slideshow player, propietary-format movie player, game console. But with Linux and the Blender Game Kit, OpenGL, SDL, etc., this is a garage game coder’s dream workstation on the cheap, with high-definition accelerated 3D graphics, surround sound, and all kinds of fun wireless tech at the developer’s fingertips. At $600 for a 60 GB model with 512 MB of RAM, it would make a nicer Linux computer than most sub-$1000 Windows PCs out there.

Perhaps a cottage gaming industry will grow out of the PS3 Linux strategy, like the GP32’s in Korea. Which makes this Linux play by Sony the direct competitor to Microsoft’s XNA move. You see, both Sony and Microsoft see independent game developers as the future savior of the game industry.

The big game publishers and developers screwed themselves, just as the MPAA and RIAA did, by making production ever more expensive, formulaic, and insipidly uncreative, and by depending on the quarterly mega-blockbuster to survive. They did this at a time when more people than ever have access to the means of production and distribution of digital creative content.

The goal of Sony’s Linux strategy and of Microsoft’s XNA, is to attract the independent game developers to their respective platforms. Microsoft believes that giving the tools away for “free as in free beer,” while keeping the secret sauce bottled up, is the successful strategy. Sony believes making the tools as open as possible without screwing the pooch is the the best strategy.

Now, as an open source fan, I will argue that a truly open community of coders, without central control and oversight, is going to prevail over the “you must please the gatekeeper” culture Microsoft wants to impose with XNA on XBox360.

But let’s not be too idealistic and see this independent game developer thing for what it really is. Just like IBM’s open source moves and Tim O’Reilly’s publishing strategy, both Microsoft’s and Sony’s strategies are all about the alpha geek mind share, and self-interest in the increase in revenue it generates.

But cynical as that may sound, open source is still the better thing. It gives more control to the developer and imposes less order, which leads to greater opportunity for creativity to go where it may. Anything less than an open technology and open community will stave off innovation before it even has a chance to set in.

Technorati Tags:
, , , , , , , , , ,

]]>
http/blawg/2007/01/22/whats-the-deal-with-ps3-linux-simple-xna/feed/ 3
Say what?!? http/blawg/2007/01/17/say-what/ http/blawg/2007/01/17/say-what/#comments Wed, 17 Jan 2007 06:58:45 +0000 http/blawg/2007/01/17/say-what/ Continue reading ]]> I receive some mailings from Sun every month. And for the most part, they are entertaining. As in laugh out loud hysterical. But this one takes the cake.


Easier, faster, and more secure the Solaris 10 OS is the only operating system robust enough to address enterprise security, compliance, and business continuity concerns, and at a lower cost and running across more hardware platforms than any other OS on the market.

Excuse me, but “more hardware platforms than any other OS on the market?” I don’t know what Sun’s definition of platform is, but last I checked, Solaris didn’t run on HP PA-RISC and IBM S/390s. Linux does, though. Linux runs on all three platforms that Solaris runs on **snort, yeah they’re beating their chest over three platforms** and then some. And I bet that when they say “OS on the market,” they mean commercially supported OS. Which conveniently disqualifies NetBSD, which is available for over forty platforms.


Hear from Sun’s Vice President of Software Marketing, Peder Ulander, and Vice President of Services Marketing, Brian Winter about how Sun’s Solaris 10 Operating System — the only multiplatform, free, and open source enterprise-class OS on the market — allows you to leverage existing infrastructure investments and anticipate rapid growth by bringing applications and services online more quickly, and at lower support costs, than any other commercial OS offering, including Red Hat, HP-UX, AIX, and Windows.

Whoa, Nelly! “The only multiplatform, free, and open source enterprise-class OS on the market”. That’s likely to get you thrown in court in most free countries, never mind hanged in those run by Sharia law! I’m not saying that Solaris isn’t free, or that it isn’t open source, or that it isn’t multi-platform. I guess 3 platforms does count as multi-platform.

But my beef is with “only”. Say what?!? Are you so desperate, Sun Microsystems, that you have to resort to outright lies? No outgoing links on this post for you, Sun!

For the record, I do like Solaris. It’s false claims like these from Sun which I despise.

Technorati Tags:
, , ,

]]>
http/blawg/2007/01/17/say-what/feed/ 0
Funky fun with computers, #1 http/blawg/2007/01/12/funky-fun-with-computers-1/ http/blawg/2007/01/12/funky-fun-with-computers-1/#comments Fri, 12 Jan 2007 10:16:57 +0000 http/blawg/2007/01/12/funky-fun-with-computers-1/ Continue reading ]]> This sounds like fun!

Whistle while you work: Use the open source sndpeek program and a simple Perl script to read specific sequences of tonal events — literally whistling or humming at your computer — and run commands based on those tones.

I can just imagine the “Star Trek XXXIV: Superfluous” movie scene now, with the brand spanking new Enterprise, the NCC-1701-ZZXYZ.

Lieutenant Atad: Snognilk on the bridge!

Captain Dracip: Commander Rekir, set the auto-destruct sequence on the main computer, quick!

** Commander Rekir begins whistling the tune from “Bridge Over The River Kwai” a.k.a. “Colonel Bogey March” **

]]>
http/blawg/2007/01/12/funky-fun-with-computers-1/feed/ 0
autossh and screen for remote login peace of mind http/blawg/2007/01/07/autossh-and-screen-for-remote-login-peace-of-mind/ http/blawg/2007/01/07/autossh-and-screen-for-remote-login-peace-of-mind/#comments Sun, 07 Jan 2007 15:47:17 +0000 http/blawg/2007/01/07/autossh-and-screen-for-remote-login-peace-of-mind/ Continue reading ]]> Unix server administrators everywhere are probably too familiar with connection timeouts when administering remote servers. There you are, dutifully editing that configuration file, when suddenly your text editor no longer responds to your cursor keys. A dozen seconds later or so, SSH reports the connection has been lost. If you didn’t save your file recently, you probably mutter a curse, for you probably have to redo your work all over again.

There is nothing worse than having to administer a server through a bad connection. When you are disconnected, having to reconnect, login, and navigate to where you last were, can knock you out of the flow of what you were doing, severely affecting your productivity.

screen to the rescue

Back in the time of the dinosaurs and dial-up, some GNU hackers, tired of the inconvenience just described, invented the screen application. screen creates a virtual console running on the server, which keeps the user logged in to the server, even when the network connection is lost. With screen, you will never lose your place while logged in remotely again, baring a reboot, shutdown, or power-loss to the server itself (alas, screen is not magic.)

screen can do much more than this simple description so far hints at. You can learn more from the online manual (type man screen at the command-line.) But for this hack, the following is all you need to remember:

Type in screen -DR when you first connect to your server, and your login session will be preserved through network disconnections. If you get disconnected, login again, and type screen -DR to return to your session, just as you left it.

The screen trick is all well and good. But we like to do things thoroughly at pjtrix, and try to find a full solution to the problem. :-) So on to autossh we go.

autossh: aim for the kill

Keeping with the dinosaurs and dial-up theme, autossh is like an auto-redialer. It faithfully tries to reconnect you to your server again as soon as it detects the connection is gone. It does this by creating an SSH tunnel loop between your workstation and the remote server, and monitors it repeatedly for lost messages.

Using autossh is almost like using ssh: except for the connection monitoring specifics, autossh simply passes all command-line parameters to ssh, and after entering the command-line, all user interaction is done through the running ssh instance. To use autossh effectively with screen, type the following command to first connect to your remote server (use this command instead of ssh):


autossh -M monitoring-port -t username@server.domain.tld “screen -DR”

For example:


autossh -M 20000 -t webmaster@pjtrix.com “screen -DR”

With the above command, autossh creates an SSH tunnel loop with ports 20,000 and 20,001 for monitoring the connection; the -t parameter makes ssh create a pseudo-terminal when it connects to the server; ssh connects to the server pjtrix.com as user webmaster; and finally, ssh runs the command screen -DR remotely on the server immediately upon a successful connection and user authentication.

If for any reason the connection to the server drops, autossh detects this, and starts another ssh session, with the same commands. This effectively reconnects you to the server, logs you back in, and returns you to your screen session, right where you left off.

Used together, autossh and screen are real peace of mind savers for Unix system administrators. Couple this hack with an SSH authentication agent and SSH keys, and you don’t even have to remember your server password between reconnects.

Truly, there can never be greater Unix administration bliss than this.

Technorati Tags:
, ,

]]>
http/blawg/2007/01/07/autossh-and-screen-for-remote-login-peace-of-mind/feed/ 2