The conversation on this page has been archived and is no longer active.

Running shell script when laptop is closed

Message #1 - Posted 2005/12/12 - DJ Craig

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?

Message #2 - Posted 2005/12/12 - John Johnson

Previously, DJ Craig 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.

Later,
John

johajohn@indianahoosiers.edu

'indiana' is a 'nolnn' and 'hoosier' is a 'solkk'. Indiana doesn't solkk.

Message #3 - Posted 2005/12/13 - Bob Harris

Previously, DJ Craig 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

Message #4 - Posted 2005/12/13 - John Johnson

Previously, John Johnson wrote:

Previously, DJ Craig 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 <gasp> check my answer (would that I had done so before posting...). Thanks for keeping me honest.

Later,
John

johajohn@indianahoosiers.edu

'indiana' is a 'nolnn' and 'hoosier' is a 'solkk'. Indiana doesn't solkk.

Message #5 - Posted 2005/12/14 - Dave-tx

On 12 Dec 2005 08:02:24 -0800, DJ Craig 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

Need Help? Have a Question?

Looking for more help, comments, and answers?

Ask your questions on Ask Different. Ask Different is a community of Apple users ready to help.