Jump to content

[HOW TO] Ever want to make a certain terminal script run at startup?


mtrog007
 Share

24 posts in this topic

Recommended Posts

I made a post in mac osx installation about me having a problem with my usb drive not properly loading and I had found a terminal script to make it work. Problem was that I didn't feel like typing it in every time I booted up.

 

This is what you have to do per ~pcwiz ::

 

Gather your code (my code for fixing my usb for instance is this)

 

rm -R /System/Library/Extensions/Caches/

 

Simply open up Applications >> AppleScript >> Script Editor

 

Type in ::

 

do shell script "insert code here" with administrator privileges

 

Note :: If the command does not need to be run as a root (with sudo superuser privileges), DO NOT put in "with administrator privileges"

 

In my case, I would put in ::

 

do shell script "rm -R /System/Library/Extensions/Caches/" with administrator privileges

 

Note :: If you have multiple commands you would like to use in your script, you can put in multiple "do shell script" lines (one for each command)

 

Now go to File >> Save As. Save it as an Application Bundle and in your whichever specified folder you want (mine will be in my applications folder). Double click it and it will ask you for your user password, then it will delete the caches directory (all as in my case). To have this run at startup, go to System Preferences >> Accounts >> Login Items and add it to the login items.

 

101% credit goes to ~pcwiz

Link to comment
Share on other sites

Lol 101% credit :D Thanks for posting this mtrog007, will help many, I think this should be stickied ;)

 

wonderful! is there a topic somewhere with useful scripts to run? e.g. I'd like to know the script to wake the display from sleep. Right now I have a corner of the display set to activate wake/sleep via mouse over. How would I make a script for that?

 

thanks again

Link to comment
Share on other sites

even an easier solution:

put this in /etc/rc.local

#!/bin/sh
rm -R /System/Library/Extensions/Caches/

 

make it executable (chmod 755)

 

No need of writing passwords also

 

Some say /etc/rc.local and /etc/rc.shutdown.local on Leopard are deprecated but still works (I tested it).

 

great - so now you can change your sig .. :wacko:

Already edited.

 

btw: Please read and follow the Signature and Avatar Rules

 

 

Lol 101% credit :P Thanks for posting this mtrog007, will help many, I think this should be stickied :P

Yes, but fisrt make it easy to read, everything centered is very "fancy" but hard to read.

Link to comment
Share on other sites

@macgirl

 

I want to try your solution to not keep typing in password. However, /etc/rc.local? I can't even navigate to this on my computer. Little more detailed?

 

Oh, and to tidy up my post I need some help. Is there any way I can make the "code" boxes smaller, or do I need to use "quote" boxes? Would you like it to not be centered?

 

Edit: Also, thanks for tidying up my signature <_<

Link to comment
Share on other sites

mtrog007,

 

You'll have to use some Terminal to edit it. Open Terminal, get into superuser mode (sudo -s or sudo su) and enter this:

 

nano /etc/rc.local

 

Edit it as you want and save it ;)

Link to comment
Share on other sites

I typed it in, and I understand how to make it executable (chmod 755), but exactly how is my question. I'm supposed to make it "chmod 755 filename.sh" but someone's gonna have to walk me through this. Terminal = not my thing.

Link to comment
Share on other sites

I hate to keep asking, but how the hell am I getting bus error?

 

all I'm doing is navigating to /etc/rc.local

 

writing:

 

#!/bin/sh

rm -R /System/Library/Extensions/Caches/

 

write out

chmod -R 755 /etc/rc.local/usbfix.sh

 

===

 

Bus error

 

???

Link to comment
Share on other sites

I give up. Fu you bus error.

 

I really do give up!

 

***

 

sudo -s

password

nano /etc/rc.local

#!/bin/sh

[sudo] rm -R /System/Library/Extensions/Caches/

control o (write out)

chmod [-R] 755 /etc/rc.local/usbfix.sh

enter

 

===

 

bus error

 

[] is for possible combinations. I have tried everything I can think of!

Link to comment
Share on other sites

 Share

×
×
  • Create New...