# Cool Mac OS X shell scripts?



## d1taylor (Jan 13, 2003)

I'm seeking some way cool shell scripts that are specifically for Mac OS X. Anyone have one to nominate?  And/or one they'd like to see?  Thanks!!


----------



## wiz (Jan 13, 2003)

does your signature describe you?


----------



## d1taylor (Jan 13, 2003)

um, versus, what?  Yeah, my signature describes one facet of my professional life.


----------



## gatorparrots (Jan 14, 2003)

Did you get the one for backing up an Entourage database to a CD?
http://www.macosx.com/forums/showthread.php?s=&threadid=26336


----------



## gatorparrots (Jan 14, 2003)

Here's a good one for creating a "Force-empty trash" script:
http://www.macfora.com/forums/showthread.php?postid=109286#post109286


----------



## michaelsanford (Jan 21, 2003)

I wrote one that pulls your IP address and prints it to a formatted HTML page and then uploads that to a server, automatically every 20 minutes. It's a simpler way to work around dynamic-DNS clients and stuff...


----------



## AeroPhool (Jan 22, 2003)

sudo periodic daily
sudo periodic weekly
sudo periodic monthly

Not really 'exciting', but maintenance is always important...


----------



## d1taylor (Jan 22, 2003)

Thanks everyone. Here's what I have on my list of OSX scripts, so far:

*Chapter 8. Mac OS X Hacks*
#87 Renice a job by process name
#88 Start FTP/Apache from the command line
#89 New version of ?open? that searches for named apps
#90 iPod music list generator
#91 NetInfo friendly version of Adduser
#92 NetInfo friendly version of quota
#93 Parsing XML Data Files
#94 Emptying the Trash
#95 Backup Data to CDROM
#96 Time Spent Online

If any of those inspire other possible scripts, that'd be way cool. AeroPhool, I already have a "run routine cron jobs by hand" script earlier in my manuscript.


----------



## dani++ (Jan 23, 2003)

I am not in front of my CUBE but I'll try to pull some ideas from chemical memory.

There is a version of 'cat' that can accept input and spit it out via Apple speech routines. Source code available (pretty trivial). Many things can be greatly enhanced by this, MacOSX only. Can't remember where I did find it, you can do a google dig.

There is 'pipealert' (versiontracker or macupdate will also give info) that outputs its standard IO to a MacOSX Aqua alert box. Also many possible uses.

And of course, there are the 'osa'* utils that can greatly enhance your life via AppleScript magic. =)

(I suppose that you'll properly quote if you use any of these and other posts ideas in any book).

dani++


----------



## 96.9 (Jan 25, 2003)

When I started writing code again I found that writing shell scripts for unix was very demanding of knowledge of not only unix sys admin but the C programming language .

You can write some crazy scripts .


----------



## d1taylor (Jan 25, 2003)

Of the C programming language?  An interesting comment. Were you stuck in the cursed C Shell, then?  I personally am a fan of Bash, and give great kudos to Apple for adding it and giving a good alternative to the adequate, but not as capable zsh shell. [my opinion, your milage will unquestionably vary]


----------



## kilowatt (Jan 27, 2003)

Here's my favorite. Actually, I just put it in my .bashrc file (~/.bashrc):

```
alias why="if [ \$RANDOM -gt 16384 ]; then echo 'because'; else echo 'why not'; fi"
```

So, next time you're ticked off at osx (or any unix) just ask it `why`. It will respond like a five-year-old.


----------



## d1taylor (Jan 27, 2003)

cute. Of course, there's a whole series of these Unix jokes like "Got a match?' {type it in}.

In other news, the OSX chapter has been axed from my book as of this point. I continue to lobby, but there are other OSX-specific titles in the works. The good news is that almost every one of the other 90 scripts in my upcoming book work great in Jaguar, etc.


----------

