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

Command line to put OS X to (deep) sleep?

Message #1 - Posted 2002/03/23 - Steven Kan

I'm trying to do some experimentation with Wake-On-LAN with my Mac, and I can't test anything until it's gone to sleep.

The shortest amount of time for sleep in the Energy Saver is 5 minutes, and it takes a long time to test things if I have to wait 5 minutes in between every time!

Is there a command line to put OS X to sleep?

A rich man who hailed from Seattle #``````` Wrote Win95 to do battle, # ``````` But Mac users pity # ``````` The masses not witty # ``````` Enough to know Wintel's for cattle. #. ``````` ~ ~ . \_@_/ ```````
^_@ o . V ```````
Steven "Rocket Man" Kan `-' - \_@_ ~ . ###### mailto:steven@kan.org V \ ~ . ###### http://www.kan.org ~ . #H2O## Everybody S.H.I.N.E. ~ .#POLO# Support Heterogeneity In Networked Environments ~ ~ ######

Message #2 - Posted 2002/03/24 - Andrew Forsyth

On 23-03-2002 23:04, in article 3C9D0928.6792E320@kan.org, Steven Kan wrote:

I'm trying to do some experimentation with Wake-On-LAN with my Mac, and I can't test anything until it's gone to sleep.

The shortest amount of time for sleep in the Energy Saver is 5 minutes, and it takes a long time to test things if I have to wait 5 minutes in between every time!

Is there a command line to put OS X to sleep?

Not that I'm aware of, how about an osascript calling an AppleScript function (don't know hat AppleScript function it is)

A.

Message #3 - Posted 2002/03/23 - ZnU

Previously, Steven Kan wrote:

I'm trying to do some experimentation with Wake-On-LAN with my Mac, and I can't test anything until it's gone to sleep.

The shortest amount of time for sleep in the Energy Saver is 5 minutes, and it takes a long time to test things if I have to wait 5 minutes in between every time!

Is there a command line to put OS X to sleep?

Uh.... Can't you just use the sleep command in the Apple menu? Anyway, if you really want to do it from the command line, the only way I know of is to call AppleScript:

osascript -e 'tell application "Finder" to sleep'

"We are living in a world today where lemonade is made from artificial flavors, and furniture polish is made from real lemons." --Alfred E. Newman

Message #4 - Posted 2002/03/24 - Tom Stiller

Previously, Steven Kan wrote:

I'm trying to do some experimentation with Wake-On-LAN with my Mac, and I can't test anything until it's gone to sleep.

The shortest amount of time for sleep in the Energy Saver is 5 minutes, and it takes a long time to test things if I have to wait 5 minutes in between every time!

Is there a command line to put OS X to sleep?

The easiest way is to choose Sleep from the Apple menu. If you want aa AppleScript you can:

tell application "Finder"
sleep
end tell

Tom Stiller

PGP fingerprint = 5108 DDB2 9761 EDE5 E7E3 7BDA 71ED 6496 99C0 C7CF

Message #5 - Posted 2002/03/24 - G.T.

ZnU wrote:

Previously, Steven Kan wrote:

I'm trying to do some experimentation with Wake-On-LAN with my Mac, and I can't test anything until it's gone to sleep.

The shortest amount of time for sleep in the Energy Saver is 5 minutes, and it takes a long time to test things if I have to wait 5 minutes in between every time!

Is there a command line to put OS X to sleep?

Uh.... Can't you just use the sleep command in the Apple menu?

That's probably what he's looking for but that's kind of hard to do from a cron job, eh?

Anyway,
if you really want to do it from the command line, the only way I know of is to call AppleScript:

osascript -e 'tell application "Finder" to sleep'

Cool.

Greg

Message #6 - Posted 2002/03/23 - ZnU

Previously, G.T. wrote:

ZnU wrote:

Previously, Steven Kan wrote:

I'm trying to do some experimentation with Wake-On-LAN with my Mac, and I can't test anything until it's gone to sleep.

The shortest amount of time for sleep in the Energy Saver is 5 minutes, and it takes a long time to test things if I have to wait 5 minutes in between every time!

Is there a command line to put OS X to sleep?

Uh.... Can't you just use the sleep command in the Apple menu?

That's probably what he's looking for but that's kind of hard to do from a cron job, eh?

Anyway, if you really want to do it from the command line, the only way I know of is to call AppleScript:

osascript -e 'tell application "Finder" to sleep'

Cool.

Well, except that I'm reasonably sure you can't call AppleScript from the command line unless you're logged in as a GUI user, so this won't be useful for cron jobs or remote access.

"We are living in a world today where lemonade is made from artificial flavors, and furniture polish is made from real lemons." --Alfred E. Newman

Message #7 - Posted 2002/03/24 - Andrew Forsyth

This message is in MIME format. Since your mail reader does not understand

this format, some or all of this message may not be legible.

--B_3099774699_577445
Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit

On 24-03-2002 00:24, in article znu-E049AF.19244523032002@news.fu-berlin.de, ZnU wrote:

Previously, G.T. wrote:

ZnU wrote:

Previously, Steven Kan wrote:

I'm trying to do some experimentation with Wake-On-LAN with my Mac, and I can't test anything until it's gone to sleep.

The shortest amount of time for sleep in the Energy Saver is 5 minutes, and it takes a long time to test things if I have to wait 5 minutes in between every time!

Is there a command line to put OS X to sleep?

Uh.... Can't you just use the sleep command in the Apple menu?

That's probably what he's looking for but that's kind of hard to do from a cron job, eh?

Anyway, if you really want to do it from the command line, the only way I know of is to call AppleScript:

osascript -e 'tell application "Finder" to sleep'

Cool.

Well, except that I'm reasonably sure you can't call AppleScript from the command line unless you're logged in as a GUI user, so this won't be useful for cron jobs or remote access.

Try this

#!/bin/zsh -->

# call osascript and redirect it's output to the bit bucket /usr/bin/osascript <<HERE > /dev/null

tell application "Finder"

sleep

end tell

HERE

A.

--B_3099774699_577445
Content-type: text/html; charset="US-ASCII" Content-transfer-encoding: quoted-printable

<HTML>
<HEAD>
<TITLE>Re: Command line to put OS X to (deep) sleep?</TITLE> </HEAD>
<BODY>
<FONT SIZE=3D"1"><FONT FACE=3D"Verdana">On 24-03-2002 00:24, in article znu-E04= 9AF.19244523032002@news.fu-berlin.de, &quot;ZnU&quot; &lt;znu@znu.dhs.org&gt= ; wrote:<BR>
<BR>
<FONT COLOR=3D"#0000FF">&gt; In article &lt;3C9D1B3C.8030604@sbcglobal.net&gt= ;,<BR>
&gt; &quot;G.T.&quot; &lt;ethan_t@sbcglobal.net&gt; wrote:<BR> &gt; <BR>
</FONT><FONT COLOR=3D"#008000">&gt;&gt; ZnU wrote:<BR> </FONT><FONT COLOR=3D"#FF0000">&gt;&gt;&gt; In article &lt;3C9D0928.6792E320@= kan.org&gt;, Steven Kan &lt;steven@kan.org&gt; <BR> &gt;&gt;&gt; wrote:<BR> &gt;&gt;&gt; <BR>
&gt;&gt;&gt; <BR>
</FONT><FONT COLOR=3D"#800080">&gt;&gt;&gt;&gt; I'm trying to do some experim= entation with Wake-On-LAN with my Mac, <BR> &gt;&gt;&gt;&gt; and I can't test anything until it's gone to sleep.<BR> &gt;&gt;&gt;&gt; <BR> &gt;&gt;&gt;&gt; The shortest amount of time for sleep in the Energy Saver = is 5 <BR>
&gt;&gt;&gt;&gt; minutes, and it takes a long time to test things if I have= to wait <BR>
&gt;&gt;&gt;&gt; 5 minutes in between every time!<BR> &gt;&gt;&gt;&gt; <BR> &gt;&gt;&gt;&gt; Is there a command line to put OS X to sleep?<BR> </FONT><FONT COLOR=3D"#FF0000">&gt;&gt;&gt; <BR> &gt;&gt;&gt; <BR>
&gt;&gt;&gt; Uh.... Can't you just use the sleep command in the Apple menu?= <BR>
</FONT><FONT COLOR=3D"#008000">&gt;&gt; <BR> &gt;&gt; That's probably what he's looking for but that's kind of hard to d= o <BR>
&gt;&gt; from a cron job, eh?<BR> &gt;&gt; <BR>
</FONT><FONT COLOR=3D"#FF0000">&gt;&gt;&gt; Anyway, if you really want to do = it from the command line, the only <BR> &gt;&gt;&gt; way I know of is to call AppleScript:<BR> &gt;&gt;&gt; <BR>
&gt;&gt;&gt; osascript -e 'tell application &quot;Finder&quot; to sleep'<BR=

&gt;&gt;&gt; <BR>

</FONT><FONT COLOR=3D"#008000">&gt;&gt; <BR> &gt;&gt; Cool.<BR>
</FONT><FONT COLOR=3D"#0000FF">&gt; <BR> &gt; Well, except that I'm reasonably sure you can't call AppleScript from = <BR>
&gt; the command line unless you're logged in as a GUI user, so this won't = <BR>
&gt; be useful for cron jobs or remote access.<BR> <BR>
Try this<BR>
</FONT><BR> </FONT></FONT><BLOCKQUOTE><FONT SIZE=3D"1"><FONT FACE=3D"Verdana">#!/bin/zsh --= &gt;<BR>
<BR>
# call osascript and redirect it's output to the bit bucket<BR> /usr/bin/osascript &lt;&lt;HERE &gt; /dev/null<BR> <BR>
tell application &quot;Finder&quot;<BR> <BR>
sleep <BR>
<BR>
end tell<BR>
<BR>
HERE <BR> </FONT></FONT></BLOCKQUOTE><FONT SIZE=3D"1"><FONT FACE=3D"Verdana"><BR> A.</FONT></FONT>
</BODY>
</HTML>

--B_3099774699_577445--

Message #8 - Posted 2002/03/24 - David C.

Steven Kan wrote:

I'm trying to do some experimentation with Wake-On-LAN with my Mac, and I can't test anything until it's gone to sleep.

The shortest amount of time for sleep in the Energy Saver is 5 minutes, and it takes a long time to test things if I have to wait 5 minutes in between every time!

Is there a command line to put OS X to sleep?

I don't know about command-line, but I know that if I push the power button on my G4 tower while the computer's on, it will go to sleep.

-- David

Message #9 - Posted 2002/03/24 - zoara

Andrew Forsyth wrote:

--B_3099774699_577445
Content-type: text/html; charset="US-ASCII" Content-transfer-encoding: quoted-printable

<HTML>
<HEAD>
<TITLE>Re: Command line to put OS X to (deep) sleep?</TITLE> </HEAD>
<BODY>
<FONT SIZE="1"><FONT FACE="Verdana">On 24-03-2002 00:24, in article <znu-E049AF.19244523032002@news.fu-berlin.de, &quot;ZnU&quot; <&lt;znu@znu.dhs.org&gt; wrote:<BR>
<

Please don't post HTML in usenet.

-z-

The devil may have the best tunes, but his operating system sucks.

Are you posting responses that are easy for others to follow? http://www.greenend.org.uk/rjk/2000/06/14/quoting

Message #10 - Posted 2002/03/24 - Andrew Forsyth

On 24-03-2002 21:13, in article 1f9k2vi.19e3ce1n0zafhN%not@all.valid, zoara wrote:

Andrew Forsyth wrote:

--B_3099774699_577445
Content-type: text/html; charset="US-ASCII" Content-transfer-encoding: quoted-printable

<HTML>
<HEAD>
<TITLE>Re: Command line to put OS X to (deep) sleep?</TITLE> </HEAD>
<BODY>
<FONT SIZE="1"><FONT FACE="Verdana">On 24-03-2002 00:24, in article <znu-E049AF.19244523032002@news.fu-berlin.de, &quot;ZnU&quot; <&lt;znu@znu.dhs.org&gt; wrote:<BR>
<

Please don't post HTML in usenet.

-z-

Unintentional error. Will check settings.

A.

Message #11 - Posted 2002/03/25 - Steven Kan

Heh! Thanks for all the (incredibly obvious) responses. I'd been stumbling along for so long without a working "sleep" feature, that'd forgotten about the obvious ones!

A rich man who hailed from Seattle #``````` Wrote Win95 to do battle, # ``````` But Mac users pity # ``````` The masses not witty # ``````` Enough to know Wintel's for cattle. #. ``````` ~ ~ . \_@_/ ```````
^_@ o . V ```````
Steven "Rocket Man" Kan `-' - \_@_ ~ . ###### mailto:steven@kan.org V \ ~ . ###### http://www.kan.org ~ . #H2O## Everybody S.H.I.N.E. ~ .#POLO# Support Heterogeneity In Networked Environments ~ ~ ######

Message #12 - Posted 2002/03/24 - Kevin Michael Vail

Previously, Steven Kan wrote:

Heh! Thanks for all the (incredibly obvious) responses. I'd been stumbling along for so long without a working "sleep" feature, that'd forgotten about the obvious ones!

I start stumbling along when I go too long with a working sleep feature, too.

-)

--

Kevin Michael Vail | a billion stars go spinning through the night, kevin@vaildc.net | blazing high above your head.
. . . . . . . . . | But _in_ you is the presence that
. . . . . . . . . | will be, when all the stars are dead. (Rainer Maria Rilke)

Message #13 - Posted 2002/03/25 - zoara

Andrew Forsyth wrote:

Please don't post HTML in usenet.

-z-

Unintentional error. Will check settings.

Nice one, cheers.

-z-

The devil may have the best tunes, but his operating system sucks.

Are you posting responses that are easy for others to follow? http://www.greenend.org.uk/rjk/2000/06/14/quoting

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.