<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div style="-webkit-text-size-adjust: auto; ">What you need to find out is:</div><div style="-webkit-text-size-adjust: auto; "> 1) How well your mobo and Linux kernel handles suspending and unsuspending.  (I have ~150 machines at work that will not wake up by any means if suspended and have to be power-cycled to make them useable again, so this might scupper you.)</div><div style="-webkit-text-size-adjust: auto; "> 2) What command-line programs SAMBA provides for seeing what files are open by remote users and what output and exit codes the programs return when the number of users is zero.</div><div style="-webkit-text-size-adjust: auto; "> 3) As (2), but for whatever the AFP service suite is called.<br></div><div style="-webkit-text-size-adjust: auto; "><br>Bash will let you call programs and examine exit codes from the last run program directly; to examine output messages, you can use grep to see whether a pre-determined pattern was found in the output.  A guide for exit code testing: <span style="font-family: '.HelveticaNeueUI'; font-size: 15px; line-height: 19px; white-space: nowrap; -webkit-tap-highlight-color: rgba(26, 26, 26, 0.296875); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); -webkit-text-size-adjust: none; "><a href="http://linuxcommando.blogspot.co.uk/2008/03/how-to-check-exit-status-code.html">http://linuxcommando.blogspot.co.uk/2008/03/how-to-check-exit-status-code.html</a>. You will also need to set up an entry in /etc/crontab (or put your script in the right /etc/cron folder) to make it happen every hour/day/whenever.</span></div><div><font face=".HelveticaNeueUI" size="1"><span style="line-height: 19px; white-space: nowrap; -webkit-tap-highlight-color: rgba(26, 26, 26, 0.292969); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469);"><br></span></font></div><div><font face=".HelveticaNeueUI" size="1"><span style="line-height: 19px; white-space: nowrap; -webkit-tap-highlight-color: rgba(26, 26, 26, 0.292969); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469);">If this is to run on a machine that's mission-critical, you need to test a lot and be sure that your kernel handles suspending and wake on LAN properly every time, but also think carefully about whether the risk of having the machine not wake up is worth the power saving.  You also need to be aware that your script might no longer be safe after a kernel patch or change of *any* piece of hardware (I had a mouse once that wouldn't work after my pc had been suspended and woken up (the led went out and wouldn't come back on) yet this mouse was fine with a different mobo), so updates or repairs will require you to turn off the script until you can test it again.  <br></span></font><br><span style="-webkit-text-size-adjust: auto;">Kind regards,</span></div><div style="-webkit-text-size-adjust: auto; ">Helen</div><div style="-webkit-text-size-adjust: auto; "><br>On 16 Dec 2012, at 21:48, Andrew Glass <<a href="mailto:andrewglass3@gmail.com">andrewglass3@gmail.com</a>> wrote:<br><br></div><blockquote type="cite" style="-webkit-text-size-adjust: auto; "><div><span>Can you help me please?</span><br><span></span><br><span>Ive never done bash scripting before however id like to write a simple script that would check for active afp users/smb users and if its idle for the machine to sleep - if there are active users it does nothing.  Id also like this machine to wake from lan.  Im using an intel pro 1000 gigabit eth card.</span><br><span></span><br><span>Any advice would be most gratefully welcomed :)</span><br><span></span><br><span></span><br><span>Cheers</span><br><span></span><br><span>Andy</span><br><span></span><br><span></span><br><span></span><br><span>_______________________________________________</span><br><span>Durham mailing list   -   <a href="mailto:Durham@mailman.lug.org.uk">Durham@mailman.lug.org.uk</a></span><br><span><a href="https://mailman.lug.org.uk/mailman/listinfo/durham">https://mailman.lug.org.uk/mailman/listinfo/durham</a></span><br><span><a href="http://www.nelug.org.uk/">http://www.nelug.org.uk/</a></span><br></div></blockquote></body></html>