Running shell script when laptop is closed

DJ Craig wrote on :
I have a 15-inch 1.7 GHz PowerBook running OS X Tiger. When I'm troubleshooting Windows LANs, I often hook my laptop into them so I can use command-line programs like nmap and nc on them. This is fine for smaller networks, but it gets to be very tedious in networks that have been divided into lots of smaller networks with routers. What I want to do is be able to just leave a shell script running in a continuous loop, and then just connect the laptop into the LAN for a few minutes, let the shell script run, then unplug it and move on to the next segment. But I can't find a way to get the shell script to run continuously when the laptop is closed. Is there any way to have it wake up when it detects the ethernet connection, or just not go to sleep when it's closed?
John Johnson replied on :

In article 1134403344.466623.135610@redacted.invalid, "DJ Craig" yomamaDJ1@redacted.invalid wrote:

I have a 15-inch 1.7 GHz PowerBook running OS X Tiger. When I'm troubleshooting Windows LANs, I often hook my laptop into them so I can use command-line programs like nmap and nc on them. This is fine for smaller networks, but it gets to be very tedious in networks that have been divided into lots of smaller networks with routers. What I want to do is be able to just leave a shell script running in a continuous loop, and then just connect the laptop into the LAN for a few minutes, let the shell script run, then unplug it and move on to the next segment. But I can't find a way to get the shell script to run continuously when the laptop is closed. Is there any way to have it wake up when it detects the ethernet connection,

Well, there is the option (in System preferences, Energy Saver pane, "options" tab): "Wake for Ethernet network administrator access", but I don't think that this is what you're looking for because:

  1. it still, AFAIK, requires the lid be open;
  2. it only wakes up upon receiving a "magic" packet, not general network traffic;

or just not go to sleep when it's closed?

There may be some sort of hack available to do this. Apple does not support these machines running with the lid closed. The primary reason for this is heat dissipation. IIRC, the last model of PowerBook to support running with the lid closed (e.g. when using an external display) is the PB G3 with Firewire, AKA "Pismo". ISTR hacks for the Titanium powerbooks that allowed them to do this as well, but I'm not sure. I am not aware of any means of achieving this functionality with current PowerBooks, but then I haven't particularly looked for one either, fwiw.

Bob Harris replied on :

In article 1134403344.466623.135610@redacted.invalid, "DJ Craig" yomamaDJ1@redacted.invalid wrote:

I have a 15-inch 1.7 GHz PowerBook running OS X Tiger. When I'm troubleshooting Windows LANs, I often hook my laptop into them so I can use command-line programs like nmap and nc on them. This is fine for smaller networks, but it gets to be very tedious in networks that have been divided into lots of smaller networks with routers. What I want to do is be able to just leave a shell script running in a continuous loop, and then just connect the laptop into the LAN for a few minutes, let the shell script run, then unplug it and move on to the next segment. But I can't find a way to get the shell script to run continuously when the laptop is closed. Is there any way to have it wake up when it detects the ethernet connection, or just not go to sleep when it's closed?

The only way I know to be keep the Powerbook running with the lid closed is to attach an external keyboard/monitor. This is most likely not what you want.

However, what you might consider is "SleepWatcher" as a way to run a script when the Powerbook wakes up.
http://www.versiontracker.com/dyn/moreinfo/macosx/17579

With a "SleepWatcher" script, you would move to a new location, open your Powerbook, and it would run your script. Close the Powerbook when finished. "SleepWatcher" could run another script for you at that time if you like.

                                    Bob Harris
John Johnson replied on :

In article null-B3E25F.12565212122005@redacted.invalid, John Johnson null@redacted.invalid wrote:

In article 1134403344.466623.135610@redacted.invalid, "DJ Craig" yomamaDJ1@redacted.invalid wrote:

I have a 15-inch 1.7 GHz PowerBook running OS X Tiger. When I'm troubleshooting Windows LANs, I often hook my laptop into them so I can use command-line programs like nmap and nc on them. This is fine for smaller networks, but it gets to be very tedious in networks that have been divided into lots of smaller networks with routers. What I want to do is be able to just leave a shell script running in a continuous loop, and then just connect the laptop into the LAN for a few minutes, let the shell script run, then unplug it and move on to the next segment. But I can't find a way to get the shell script to run continuously when the laptop is closed. Is there any way to have it wake up when it detects the ethernet connection,

Well, there is the option (in System preferences, Energy Saver pane, "options" tab): "Wake for Ethernet network administrator access", but I don't think that this is what you're looking for because:

  1. it still, AFAIK, requires the lid be open;
  2. it only wakes up upon receiving a "magic" packet, not general network traffic;

or just not go to sleep when it's closed?

There may be some sort of hack available to do this. Apple does not support these machines running with the lid closed.

Correcting myself: Apple does support PowerBooks running with the lid closed. I'm not sure what I was thinking about when I wrote the above, but it's incorrect, as Apple's own documents attest.

It was Bob Harris' post that made me think to actually check my answer (would that I had done so before posting...). Thanks for keeping me honest.

Dave-tx replied on :

On 12 Dec 2005 08:02:24 -0800, DJ Craig yomamaDJ1@redacted.invalid wrote:

I have a 15-inch 1.7 GHz PowerBook running OS X Tiger. When I'm troubleshooting Windows LANs, I often hook my laptop into them so I can use command-line programs like nmap and nc on them. This is fine for smaller networks, but it gets to be very tedious in networks that have been divided into lots of smaller networks with routers. What I want to do is be able to just leave a shell script running in a continuous loop, and then just connect the laptop into the LAN for a few minutes, let the shell script run, then unplug it and move on to the next segment. But I can't find a way to get the shell script to run continuously when the laptop is closed. Is there any way to have it wake up when it detects the ethernet connection, or just not go to sleep when it's closed?

Try this kernel extension:

http://www.macosxhints.com/article.php?story=20050308172947974

-Dave