Tag: command line

  • Truncate a directory

    Cooked up a script to limit the number of files in a directory to a defined value. Thought I’d mention it here under this title and preface, to make it searchable, since I didn’t find anything premade using them as search terms.

  • Make some noise

    I adapted Geek Thoughts‘ “Making Noise with ImageMagick” in creating video noise — a video simulating what you used to get when you turned on a television with no signal, back in the analog days. To combine the noise frames created by ImageMagick I used Netpbm, which I had to install separately (that is, it wasn’t installed by default in Lenny).

    Here’s the Bash multi-liner I used to generate 48 frames worth of noise:

    (for i in `seq 1 48`; \
    do convert -size 640x480 xc: +noise Random \
    -blur 1x1 -fx intensity -normalize ppm:-; done) \
    | ppmtompeg kohina.txt

    And here’s kohina.txt which specifies how ppmtompeg packs the frames. Note that I just threw this together without too much thought, so it definitely needs tweaking depending on what the video is used for and so what (quality, compression, speed) matters. For example, I only used I-frames due to lack of imagination.

    PATTERN IIIIIIII
    OUTPUT kohina.mpeg
    INPUT_DIR stdin
    BASE_FILE_FORMAT PPM
    INPUT_CONVERT *
    GOP_SIZE 8
    SLICES_PER_FRAME 30
    PIXEL HALF
    RANGE 2
    PSEARCH_ALG LOGARITHMIC
    BSEARCH_ALG SIMPLE
    IQSCALE 1
    PQSCALE 1
    BQSCALE 1
    REFERENCE_FRAME ORIGINAL

    And here’s what it looks like, recompressed with Theora (using Oggconvert): kohina.ogg (2,8 MB). Generating an accompanyng soundtrack is trivial with Audacity.

  • SSH inside a while read loop

    Got bit by the fact that SSH inherits stdin from its parent, which rendered my fancy remote-command-in-a-loop useless. Passing -n to ssh made it work the way I’d expected.

  • vrms

    Via Jacob.

    jani@gojira:~$ vrms

    No non-free or contrib packages installed on gojira!  rms would be proud.

    Well, that’s not accurate: at least I have the non-free version of VirtualBox installed. Now I’m trying to find out if this is a bug or a limitation set by something in my setup.

  • aptmethod error when doing security updates with reprepro update

    Got this error message when trying to do a reprepro update:

    aptmethod error receiving 'http://security.debian.org/debian-security/dists/lenny/updates/main/debian-installer/binary-i386/Packages.gz': '404 Not Found'

    This was caused by a missing UDebComponents: none in the security update source definition, in conf/updates. Quite obvious really, but got me scratching my head for a while.

  • The command to print the release codename

    jani@gojira:~$ lsb_release -sc
    lenny

  • Fetch and sequentially store webcam images at intervals, v. 0.01

    #!/bin/bash
    if [ $# -lt 2  ] ; then
      echo foo
      exit 1
    fi
    
    if [ $1 -eq $1 2> /dev/null ]; then
      while true
      do
        wget "$2" -O `date +%s`.jpg
        sleep $1
      done
    else
      echo bar
      exit 1
    fi
  • GRUB, subprocess post-installation script returned error exit status 1

    Note to self: the next time GRUB starts exiting with 1 during postinst (when upgrading the kernel), check /boot/grub/device.map. Apparently the last time this happened, I had to change hd0 to point to sda, and this time I had to change it to point back to hda. Without this change grub-probe would fail, causing update-grub and thus the postinst to fail also.

    Also, don’t be fooled by update-grub staying quiet; update-grub && echo success lets you know whether it did actually complete or not.

  • Creating ISO images

    I just learned that mkisofs has been superseded by genisoimage.

  • Querying dd for statistics

    To get the statistics of a running dd, you send it a USR1 with kill:

    kill -USR1 $PID