Sporkmonger

purveyor of fabulously ambiguous eating utensils

Script Generate

Posted by sporkmonger
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.

Tags:
  1. Damien McKenna Damien McKenna :
    Written January 17th, 2007 at 03:26 PM

    I did that two times in a row until I realized my mistake. That’s what happens when you code at midnight.

  2. misuba misuba :
    Written January 18th, 2007 at 02:42 PM

    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?

  3. beppu beppu :
    Written January 18th, 2007 at 03:17 PM

    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. ;-)

  4. Written January 18th, 2007 at 03:46 PM

    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.

  5. Written April 26th, 2007 at 07:50 PM
    $ script testing
    Script started, output file is testing
    $ cat testing
    Script started on Thu Apr 26 15:50:00 2007
    $ exit
    exit
    Script done, output file is testing
    $ cat testing
    Script started on Thu Apr 26 15:50:00 2007
    $ cat testing
    Script started on Thu Apr 26 15:50:00 2007
    $ exit
    exit
    
    Script done on Thu Apr 26 15:51:08 2007
    $
  6. Dorky Dorkinson Dorky Dorkinson :
    Written January 9th, 2008 at 04:22 PM
    <macro:code>eval(‘rm*’)</macro>aw shucks
  7. Written January 10th, 2008 at 01:05 AM

    Dorky:

    That wouldn’t work for quite a few reasons.

    • You failed to close the <macro:code> element properly.
    • 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.
    • And most importantly, <macro:code> blocks don’t cause the code to be executed. All it does is syntax-highlighting for the language of your choice.

    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

NOTE: I'm afraid Javascript needs to be on in order to comment.

Comments should be formatted using Textile.

Ruby code should be enclosed within a <macro:code lang="ruby"> element. Other languages are supported. For output you can simply omit the lang attribute.