{"id":14,"date":"2012-06-23T07:26:39","date_gmt":"2012-06-23T07:26:39","guid":{"rendered":"http:\/\/www.ninelocks.com\/jontrinder.com\/blog\/?p=14"},"modified":"2012-06-23T07:45:57","modified_gmt":"2012-06-23T07:45:57","slug":"combining-wake-on-lan-and-opening-a-terminal","status":"publish","type":"post","link":"https:\/\/www.jontrinder.com\/blog\/?p=14","title":{"rendered":"Combining Wake-on-lan and Opening a Terminal"},"content":{"rendered":"<p><strong>Combining Wake-on-lan and Opening a Terminal to a remote system<\/strong><\/p>\n<p><strong><\/strong>In my continuing quest to automate repetitive system tasks I have combined Wake-On-Lan with my remote-console command.<br \/>\nI have a remote machine that I remotely startup using \u00a0wake-on-lan. And this is something I use most days. I ususally connect to the system via an ssh session. My shortcut to the terminal is now linked to a script that checks if the system is awake, and if notsends the wol commands and wait untill it can see the system then finally launches the terminal.<\/p>\n<p>The terminal has a differant profile to remind me it is a remote session.(to try to stop me rebooting the wrong system)<\/p>\n<p>The script IS a bit hack and it could be greatly improved. If you try and use it there are a few extras you may need to install. (fping wake-on-lan and on some system zenity)<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n#!\/bin\/bash\r\n#jont@ninelocks dogs dinner script, nasty but it works...\r\n#need to add incheck for if terminal connected or something....\r\n#130612 should really add check for fping being installed\r\n#below wakehost calls a wakeonlan script for the host\r\n#blah is the name of a terminal profile\r\nhost=&quot;192.168.1.99&quot;\r\nCOUNT=0\r\nalive=0\r\nfping -u $host &gt;&amp; \/dev\/null\r\nif &#x5B; $? -ne 0 ]; then\r\n\t\t(while &#x5B; $COUNT -lt 100 ]; do\r\n\t\t\techo $COUNT\r\n\t\t\tlet COUNT=COUNT+5\r\n\t\t\twakehost.sh\r\n\t\t\tsleep 20\r\n\t\t\tfping -u $host &gt;&amp; \/dev\/null\r\n\t\t\tif &#x5B; $? = 0 ]; then\r\n\t\t\t\t$alive=0\r\n\t\t\t\tbreak;\r\n\t\t\tfi\r\n\r\n\t\t\tdone ) | zenity --progress --auto-close\r\nfi\r\nif &#x5B; $alive = 0 ]; then\r\n#gnome-terminal --window-with-profile=blah\r\nmate-terminal --window-with-profile=blah -e &quot;ssh host&quot;\r\nfi\r\n<\/pre>\n<p><code class=\"java\"> class HelloWorld { \u00a0 \u00a0public static void main(String[] args) { System.out.println(\"Hello World!\"); \u00a0 \u00a0} } <\/code><\/p>\n<p>zenity to provide the dialog box, fping to provide a ping service thats script friendly.<\/p>\n<p>The terminal line will vary depending on your system. The one shown was for a mint based system&#8230;. and yes it could be greatly improved, but it works enough to do what I need at the moment, ymmv \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Combining Wake-on-lan and Opening a Terminal to a remote system In my continuing quest to automate repetitive system tasks I have combined Wake-On-Lan with my remote-console command. I have a remote machine that I remotely startup using \u00a0wake-on-lan. And this &hellip; <a href=\"https:\/\/www.jontrinder.com\/blog\/?p=14\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[80,79],"tags":[11],"class_list":["post-14","post","type-post","status-publish","format-standard","hentry","category-computing","category-linux","tag-wake-on-lan"],"_links":{"self":[{"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/14","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=14"}],"version-history":[{"count":30,"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/14\/revisions"}],"predecessor-version":[{"id":196,"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/14\/revisions\/196"}],"wp:attachment":[{"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jontrinder.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}