Script for Hard drive

Thanks to both of you :slight_smile:

Hi,

I have exactly the same issue as Neur28 had but I cannot get the script to work.

Anyone with some additional thoughts/ideas on how to prevent the harddrive from shutting down every 10 minutes?

Be a bit more descriptive about “can’t get the script to work”. What does happen? You saved the script from the Script Editor as a stay-open application, right? And, in this line do shell script “touch /Volumes/External-HD-Name/.stayawake”, you substituted the name of your own HD for “External-HD-Name” in the line, correct?

I used this script:
on idle
try
do shell script “touch /Volumes/RAID 1 STORAGE/.stayawake”
end try
return 300
end idle

  • I saved the script as a stay open application on my desktop
  • The HD name is RAID 1 STORAGE which includes spaces; could this be the problem?
  • I took the HD name as it is showing on my desktop; is this OK?

As I am not an expert on Scripts: when I have saved it I just run the application and it shows up in the Dock; is this the correct way? When I do that the HD still goes to sleep after 9-10 minutes.

If we can get this to work: is there any way to run this program in the background every time the computer starts?

Your support is much appreciated.

Yes, this is the problem, the command line treats spaces as parameter delimiters.
You can solve it by quoting the path or escaping the spaces with a backslash

on idle
   try
       do shell script "touch '/Volumes/RAID 1 STORAGE/.stayawake'"
   end try
   return 300
end idle

To run the program at startup just put it into the startup items.
To hide it from the GUI the script must be saved as application bundle.
Open the application package /Contents/Info.plist and add this key

<key>LSUIElement</key> <string>1</string>

I have saved it and running it currently. Will report back later if this indeed did the trick. Thx

Looks like it’s working :slight_smile:

I put the program in the startup items but I am not sure how to hide it from the GUI.

  • How, where and with which program do I save it as an application bundle?
  • where can I find application package /Contents/Info.plist?

I hope you can help me with this one as well…

In Script Editor save the script as application bundle (not Carbon application)
Then right-click the application icon > Show Package Contents and open the Contents folder.
There is the Info.plist file

Last question: when I save it as application bundle, should I save it as Stay Open as was the setting for application?

Yes, of course

DID IT ALL AGAIN AND NOW IT’S WORKING but I will see how it goes in the next few days.

Thanks for the support

Saved it as Application Bundle with Stay Open box checked, tried to run the program and now I get this error:

You can’t open the application.
“My_Book_Studio_keep_awake.app” because it is not supported on this architecture

I have an iMac Intel with Leopard. What am I doing wrong?

Here’s a much better method than a stay open application.
In Tiger Apple has introduced launchd, which is a powerful scheduler and more

Do the following steps:

¢ Create a folder with name launchd in ~/Library/Scripts/ (~ is your home directory).
¢ Save the following script as normal compiled script with name My_Book_Studio_keep_awake.scpt in ~/Library/Scripts/launchd/

property myDisk : "RAID 1 STORAGE"

if (myDisk is in (do shell script "/bin/ls /Volumes")) then
    do shell script "/usr/bin/touch " & quoted form of (POSIX path of myDisk & "/.stayawake")
end if

¢ Create a folder with name LaunchAgents in ~/Library/ if it doesn’t exist (again in your home directory!)
¢ Create a plain text file (not rich text! check it with ⇧⌘T) in TextEdit with this content

[code]<?xml version="1.0" encoding="UTF-8"?>

Label keep.awake LowPriorityIO Program /usr/bin/osascript ProgramArguments osascript /Users/myUser/Library/Scripts/launchd/My_Book_Studio_keep_awake.scpt StartInterval 300 [/code] ¢ in the text replace [b]myUser[/b] with the short name of your user account ¢ save the text file UTF-8 encoded named [b]keep.awake.plist[/b] into ~/Library/LaunchAgents ¢ in Terminal type [b]launchctl load -w '/Users/myUser/Library/LaunchAgents/keep.awake.plist'[/b] (replace again [b]myUser[/b])

The launchd agent is now loaded an will be loaded also always at startup

Thank you for all the informative replies. I landed here via a search engine because I have the same problem as the one described the OP.
One question for StefanK: I am trying to implement your solution in the previous post (launchd method) as it seems a more robust one, but am wondering:
Do I have to replace “RAID 1 STORAGE” with the name of my disk, for instance “EXTERNAL_PIG”?

(The name is real, the Western Digital enclosure earned it)
Thank you,
Bogdan

Yes, the literal string in the property line is the name of the affected volume

Thank you, Stefan.

In the meantime I discovered that uninstalling the WD drive manager software not only gets rid of the ugly logo in my menubar, but also gets rid of the problem itself (drive unmounting). I think someone mentioned this before on a different forum.
Of course your script is the better solution, as it allows one to keep the WD software installed, with all its bells and whistles (temperature control, drives-going-bad warning, RAID setup).

I don’t mean to be pesky but could you also suggest an uninstall procedure for your launchd solution?
The script can be deleted, but what about undoing whatever changes the Terminal session made to the system configuration?

Thanks again.

Bogdan

PS: just for the record, the configuration that created my problem was: Mac OSX10.4.11 on a 1.5GHz Powerbook G4 with a WD MyBook Studio 2TB, 2’nd edition, bought as a Mac drive and configured as a mirrored RAID (1) and connected via FW800 and USB (not simultaneosly! :-).
During an overnight attempt to back up about 150GB of data, the enclosure would try to go to sleep dozens of times (accumulating piles of futile, okayable, Redmond-style dialog boxes on the screen). Finally, one of these sleep attempts would “succeed” and the copy would invariably be corrupted.

to disable the launchd agent, type in Terminal.app

launchctl unload -w '/Users/myUser/Library/LaunchAgents/keep.awake.plist'

Wow, Western Digital TechSupport is fast after all :stuck_out_tongue:
Only thing: I had no idea WD is outsourcing to Switzerland.
</haha off>
Thanks!
Bogdan

Well, after my iMac got stolen and got a new one up and running with a Time Machine backup (worked great by the way!) I tried to implement the solution of Stefan.

I followed the instructions but keep getting this message in Terminal:
launchctl: no plist was returned for: /Users/Marcel/Library/LaunchAgents/keep.awake.plist
launchctl: no plist was returned for: /Users/Marcel/Library/LaunchAgents/keep.awake.plist
nothing found to load

I checked the MyUser settings in the command and scripts etc. but cannot find the error that I made (I anticipate it’s a human error :wink:

Any tips, suggestions on how to resolve this?

Anyone who can guide me in the right direction? :confused: