Script Generate
Written January 17th, 2007
Well, here’s an interesting mistake I just made. Went to generate a model for a Rails application I’m working on, but I made a typo. Instead of entering:
script/generate model ListedParts
I accidentally typed:
script generate model ListedParts
That of course, didn’t work. It just came back with:
Script started, output file is generate
Sadly, I was unaware of the functionality of script, so of course the first thing I did after that was:
cat generate
3 seconds later, my Powerbook was locked hard, and I had a 200 MB file in my directory.
Oops.
I did that two times in a row until I realized my mistake. That’s what happens when you code at midnight.
For those of us who don’t even know where to begin googling something that hinges on such common words, what is the functionality of
script?The script command will record the output of the current shell session. After you end the script session, you can cat the file you saved it to and get a playback of everything you typed in the shell. Think of it as an old-school+low-tech alternative to screencasts. ;-)
The problem, of course, is if you cat the file while the script session is still going. It will record the contents of the file back into the file, while also displaying it on your terminal. End result is that your terminal starts scrolling forever and the file starts filling up really, really fast, and you can’t easily do anything to stop it because your computer gets really quite sluggish.
Dorky:
That wouldn’t work for quite a few reasons.
rm*doesn’t actually do anything particularly malicious, especially without permissions.eval('rm*')would not cause the statement to be executed in a shell, assuming Ruby was what was intended.Also, what’s it like out in Hawaii?
Next time, you might want to try something more constructive, like posting useful code. That’s what the <macro:code> blocks are for.
Leave a Response