Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Pause and resume resource-intensive apps via script' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Pause and resume resource-intensive apps via script
Authored by: vincentvanwylick on May 18, '06 12:32:38AM

Thanks for the hint. But how do I save it as a file, I'm pretty new at this scripting thing. Script Editor gives me the Syntax error: "an unknown token can't go there," and I can't seem to save the file.



[ Reply to This | # ]
Pause and resume resource-intensive apps via script
Authored by: DylanMuir on May 18, '06 01:02:01AM

You should just use a text editor, and save the file as plain text (with the ".pl" extension). Then you will need to make the script executable from the terminal using chmod +x scriptname.

DRM



[ Reply to This | # ]
Pause and resume resource-intensive apps via script
Authored by: SOX on May 18, '06 07:20:08AM
you can save the third (annotated) version above as an executable file like this: highlight all the text and select copy. Open up a terminal windows and type:

pbpaste > supernice.pl
chmod a+x supernice.pl
Now it's ready to run by typing:

./supernice.pl  3357 3.0 0.5
where those numbers are the process ID and the hi-lo load limits on the application you want to limit. use top or activity monitor to find the process ID.

Another way that might be slightly easier is to add this to your .cshrc or .bashrc file.

to do this copy the second form above (the one that starts with "alias supernice ...). grab all the lines in one selection. If possible select carriage returns before and after it, though this is not essential. select "copy", then open a terminal window and type:


pbpaste >> ~/.cshrc
pbpaste >> ~/.bashrc
note the double "greater than" symbols, the tilde and the period.

Now close that terminal window and open a new one (to force it to re-initialize). At this point you should be able to try


supernice  3347 3.0 0.5
and have it supernice process ID 3347 for example. Notice that in this form you don't need to specify the ".pl" suffix or the "./" prefix, since this is now a built-in alias command, not a script file. It can be run from any subdirectory, not just the directory where the script file was located.

to remove the alias if you do something wrong or simply don't like it, open the .bashrc and .cshrc in any text editor and delete the offending line. To open a hidden dot file in TextEdit you can type:


open -a TextEdit ~/.cshrc


[ Reply to This | # ]
Pause and resume resource-intensive apps via script
Authored by: SOX on May 18, '06 08:08:19AM

Alternatively see the applescript version I posted below



[ Reply to This | # ]