PowerShell Controlled Railway Signal
Written on July 2, 2014

So tonight on Twitter, SlipperySeal decided to unleash his Raspberry Pi controlled railway signals upon us. Using a web page, you can enable or disable the lights. I decided to take it one step further and hijack the page with a cheeky bit of PowerShell. I pulled out the URLs called when you update the lights, and used the Start-Sleep cmdlet to time my fake clicks.

http://pimpmylight.catchpole.net/?update=green
http://pimpmylight.catchpole.net/?update=orange
http://pimpmylight.catchpole.net/?update=red

The PowerShell to do this was quite simple:

$wc = New-Object System.Net.WebClient 
$uri = "http://pimpmylight.catchpole.net/?update=green"
while ($true) { 
  $null = $wc.DownloadString($uri); 
  "Green!"; 
  Start-Sleep -milliseconds 500 
}

Three copies, running at three different time intervals, and we had this:

Comments/questions

There's no commenting functionality here. If you'd like to comment, please either mention me (@[email protected]) on Mastodon or email me. I don't have any logging or analytics running on this website, so if you found something useful or interesting it would mean a lot to hear from you.