Main Content
Changing a screen saver from a web page (PHP, Perl, OSX) Archive - Originally posted on "The Horse's Mouth" - 2008-05-06 17:49:19 - Graham Ellis
Here's a challenge. I want to change the screen saver on a mac mini, running OSX, from a browser anywhere in the world.
You may well ask why ... the screen of the mac mini is to be visible at Well House Manor where it will provide an information screen at the front door when it's not otherwise in use, and we want it to say things like "Sorry - no Vacancies" and "Welcome to the Chamber of Commerce "
Task achieved! Using PHP ... and Perl ... and Web2 technology. With a smattering of OSX!
Here's the control widget on our web page ... the page is in PHP and this particular widget is only displayed to staff members who are logged in - if you look at our Staff Resources Page you won't see it.
And the PHP that's run when you press the update button:
if ($_POST[door] == 12) { // Door Status changed
$ds = $_POST[doorst];
$fho = fopen("door.txt","w");
fputs ($fho,stripslashes($ds)."\n");
fclose ($fho); // Host and Port changed for security
$done = file("http://zzz.wellho.net:8080/cgi-bin/dodo.pl?$ds");
}
That piece of viewing software was called a controller on the Mac - which is running as a Web Server on a port enabled on our firewall, and redirected with NATS to the Mac Mini.
The Perl software dodo.pl looks like this:
#!/usr/bin/perl
print "content-type: text/html\n\n";
print "Changing Page";
`rm -rf /Users/lisaellis/FrontDoor`;
`cp -r /Users/lisaellis/$ENV{QUERY_STRING} /Users/lisaellis/FrontDoor`;
open (FH,"ps aux|");
while (<FH>) {
if (/ScreenSaverEngine/) {
@n = split;
kill 9,$n[1];
print "$n[1]<br>";
}
}
sleep 1;
open (FH,'|/System/Library/Frameworks/ScreenSaver.framework/Versions'.
'/A/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine' );
close FH;
print "Changing Page";
And there's also a standalone version here if you want to download a copy for your own use.
You'll notice - typical use of PHP to front a web application, typical use of Perl as "glueware", and typical use of a Unix / Linux / OSX utility - in this case Mac's ScreenSaverEngine - to do the oddball job we needed.
Some other articles
Z402 - Melksham Chamber of Commerce and Industry Melksham Chamber of Commerce - my final Presidents report Annual review of Melksham Matters for Chamber of Commerce AGM The Campus in Melksham - name, logo, and livery choice Future Swindon - Westbury train services. At current level into the future? Herman Miller coming to Melksham - the Chamber of Commerce is briefed Melksham Market - every Tuesday Tell me a bit about Melksham Questions from children about Melksham Campus Melksham Chamber of Commerce - Report for AGM, 21st May 2013 Over a hundred welcoming businesses - Melksham Town Centre Report on the last year - Melksham Chamber of Commerce and Industry for Melksham Without Parish Council Costa Coffee in Melksham - is it a good idea? Images of Melksham you havent seen before Melksham Chamber of Commerce - join us in our future Quiet little town? Advanced Technology Centre? Melksham Chamber of Commerce - whence in 2013 and beyond? Chamber of Commerce - looking forward in Melksham and in Wessex The difficult interface between the business, council and voluntary sectors Bus times - Chippenham Station to Melksham, with London connections Making things happen - litter and ASB and lost dogs in Melksham The Melksham News - July 2012 - Part 1, Campus and Chamber of Commerce Melksham Pride - the Chamber of Commerce, and the future Melksham Chamber of Commerce - looking to our future shape. Pivotal meeting next Tuesday How well do you know Melksham? Melksham Visitors Map - Bus routes and train lines to and from the town Public transport for international arrivals into Melksham Not everyone has a computer - 9 more ways to learn about the Melksham Campus Go green - business seminar in Melksham Ten more visitors to your premises every day? Just 12 winners? Or 371 or more? Town Centres. Encouraging business in Melksham and its neighbourhood - keep business local?? An exciting Chamber of Commerce AGM - sound like an Oxymoron? Why do people use chains rather than independent traders? Events in Melksham - read all about them, and tell us about yours Melksham government and business organisations Wiltshire Business Support Service Melksham Business Newsreel Some advise for guest speakers at meetings Melksham Train Service - please support the TransWilts case for regular trains Changing shops and organisations - Melksham, the last and next five years Meeting Report - Tuesday 21st Feb - to Melksham Chamber of Commerce from Shadow Community Operations Board Melksham Civic Awards - report and pictures Melksham, Month by month through 2011 Melksham - changing times, an opportunity for the future Melksham - Business to Business Speed Networking - build ahead for 2012 Looking forward - Chamber of Commerce has 2012 and beyond on the agenda Upcoming events in and about Melksham - more dates for your diary Some thoughts in answer to some Melksham Campus questions Havant - Shop Frontages. Currently pictured in Melksham Melksham to become a part of Trowbridge? What is on the Melksham Agenda? 1 + 1 + 1 + 1 = 12? Making best use of the new enthusiasm for Melksham Are people who walk into Melksham being asked to subsidise parking? Melksham Jelly - An Occasional Office for Home Workers Summer Sunday Train Service Starts - Swindon Chippenham and Melksham to Weymouth Summer Sunday Timetable - TransWilts Trains A lesson from the sporran market? The Olympic Torch, and Melksham House Melksham Community Radio launches Presidents Report to Melksham Chamber of Commerce, 24.5.2011 Letter to The Editor Melksham Chamber of Commerce - grows to appoint new Press Officer. Welcome. Sam Melksham Car Parking - current charges and limits Events - Spring and Early Summer 2011 in Melksham Melksham - the way forward. 26th April, Well House Manor Vandalism and riot from the minority - the effect Melksham Campus - any last minute inputs from Melksham businesses? Melksham Campus - what, why, questions, concerns and how you can input What proportion of the British Workforce still works a Monday to Friday, 9 to 5, week? What is the Melksham Chamber of Commerce? On consultations, car parking, and Melksham town centre Keep your business customer-friendly! Wiltshire Rail services - a golden opportunity Opportunities for Melksham - new businesses in the town Trowbridge and Melksham to Chippenham - more roadworks, even slower journey over the winter Melksham - two many councils? A river in Melksham is not just for boaters. Travel, Transport and Tourism - A vision for Melksham, 2026 A Melksham news roundup Welcome to Countrywides new Melksham store Getting into and out of Wiltshire towns .. a.k.a. Car Parking? Wiltshire Council ask how they can help businesses Melksham Oak - photos of the new community school Moved - Melksham Lorry Park Cycling in Melksham, and looking forward Transport in Wessex - today and into the future Lorry Parking in Melksham Melksham - a gem in Wiltshire Tell the Melksham Chamber or you only have yourself to blame The history and future of Melksham Chamber of Commerce Melksham Chamber of Commerce - Presidents report to AGM How do our tactics help us meet the strategy, for the greater good? Car Parking in Melksham Random thoughts on Melksham Town Planning and development How is your tax pound spent? Melksham Area - your community view is sought Forums for your Melksham and open source discussions How well do you know Melksham - a quiz for Christmas Vision for Wiltshire Rock and hard place .. and the relaxing right one won Melksham - new Tuesday Market Melksham Market - Tuesdays, 09:00 to 14:00 The road show has been - where now? Community Area Partnership - inaugural AGM Planning the future of Wiltshire Melksham Forum Melksham Town - asleep or awake? New Web Site for Melksham Chamber of Commerce Wiltshire Unitary News - Chamber of Commerce Intelligence Melksham - no trains, no southbound buses through the town pre-Inaugural briefing - Melksham Community Area Partnership Wiltshire Community Area Partnerships Important - the future of Melksham / Chamber of Commerce Melksham Traders - where do we go? Melksham Business Map - Chamber of Commerce, Tourist Information and Town Council You cannot please all of the people all of the time Make your business a DESTINATION business Business Networking for Melksham - 23rd April Blue Ridge and Melksham Chambers of Commerce Confidence, Customer Service and Tourism in Melksham One Cheer for Local Democracy - Asda in Melksham Looking forward, in Melksham, in 2009 Lidl opens in Melksham Ruby, Perl, Linux, MySQL - some training notes Melksham Chamber of Commerce and Industry Wiltshire Council says - part 1 Melksham Chamber of Commerce, or the FSB All the pieces fall into place - hotel and courses Hotel room prices - Melksham, Wiltshire Summer! This article Comments on proposed Asda Superstore for Melksham Flooding by Asda-s proposed new supermarket Shopping for Christmas and looking forward Wiltshire County Council - Budget Consultation Remembrance day - inside a church and inside the day Business speed networking - a place tonight! Asda opening large new store in Melksham A customer service company P258 - Solaris, OSX and Linux Teaching examples in Perl - third and final part Pre and post increment - the ++ operator Running operating system commands in Perl This article H307 - Web2 and caching Caching results in an object for efficiency - avoiding re-calculation How do I post automatically from a PHP script to my Twitter account? Web server efficiency - saving repetition through caches Further recent PHP examples Using web services to access you data - JSON and RESTful services Handling failures / absences of your backend server nicely Building up from a small PHP setup to an enterprise one On this day ... one PHP script with three uses How to add a customised twitter feed to your site Setting your user_agent in PHP - telling back servers who you are PHP data sources - other web servers, large data flows, and the client (browser) Scraping content for your own page via PHP Uploading and Downloading files - changing names (Perl and PHP) New Example - cacheing results in PHP for faster loading Automated server heartbeat and health check Flash (client) to PHP (server) - example Javascript/HTML example, dynamic server monitor Ajax - going Asyncronous and what it means Starting Ajax - easy example of browser calling up server data memcached - overview, installation, example of use in PHP Exchange Rates - PHP with your prices in your users currency This article A164 - Services and Regular Jobs Starting MySQL. ERROR! The server quit without updating PID file - how we fixed it. Managing daemons from a terminal session The Kernel, Shells and Daemons. Greek Gods in computing On time What are .pid files? What Linux run level am I in? Using the internet to remotely check for power failure at home (PHP) daemons - what is running on my Linux server? Dialects of English and Unix memcached - overview, installation, example of use in PHP Apache httpd, MySQL, PHP - installation procedure FTP server on Fedora Linux This article Automatic startup and shutdown of Tomcat Linux run states, shell special commands, and directory structures Linux / Unix - process priority and nice Browser -> httpd -> Tomcat -> MySQL. Restarting. Repeating tasks with crontab