7-Zip is an Open Source file archiver with a high compression ratio. It's used for DriverPacks. p7zip is a Unix port of it that can also be compiled on OS X.

cd /extra/src
wget http://downloads.sourceforge.net/project/p7zip/p7zip/9.04/p7zip_9.04_src_all.tar.bz2
tar xjf p7zip_9.04_src_all.tar.bz2

Build it:

cd p7zip_9.04

Edit install.sh, if necessary, to adjust the install location (defaults to /usr/local), then install the programs:

make install


ImageMagick conversions

Helpful one-liners and small scripts for batch processing of images.

  • Drop Quality factor of JPEG files


Using CD/DVD Burners with Linux

Using mkisofs to create and burn CD/DVD images.

On CentOS:

yum install mkisofs cdrecord


mkisofs -J -l -R -r -T -V volid -allow-multidot -o filename path
  • volid - the volume id for the disk you will make. This is the label the disk will have when automatically mounted on some operating systems.
  • filename - where the filesystem image will be output. The file may be as large as 650MB (CD) or 4.7GB (DVD), so use scratch space if possible.


ImageMagick for OS X

Installing ImageMagick on OS X 10.3 (Panther) and OS X 10.6 (Snow Leopard).

Recommended Libraries

  • libtiff

    wget http://dl.maptools.org/dl/libtiff/tiff-3.8.2.tar.gz
    tar zxf tiff-3.8.2.tar.gz
    cd tiff-3.8.2
    sudo make install
  • libjpeg
    wget http://www.ijg.org/files/jpegsrc.v7.tar.gz
    tar zxf jpegsrc.v7.tar.gz
    cd jpeg-7
    sudo make install

ImageMagick installation
To get the latest version of ImageMagick:

Capturing Web Pages

Options for automating the capture of a screen shot of a web page.

Paparazzi! is an OS X application for capturing screenshots of web pages. It is AppleScriptable to automate the capture of a page:

tell application "Paparazzi!"
  capture "http://www.google.com/"
  repeat while busy
    delay 1
  end repeat
  save in POSIX file "/Users/foo/Desktop/google.png" as PNG with icon
end tell



Handy programs for scripting on OS X

  • MacOSX::File - A collection of Perl modules to manipulate files on MacOS X (set file/creator codes, copy files while preserving the resource fork,etc.)
    Installing on Panther resulted in a "gcc2" error when trying to install from CPAN. Manually still required a tweak even though the latest version has a patch for Panther:

    curl -O http://search.cpan.org/CPAN/authors/id/D/DA/DANKOGAI/MacOSX-File-0.71.tar.gz
    tar zxvf MacOSX-File-0.71.tar.gz
    cd MacOSX-File-0.71
    perl Makefile.PL
    make CC=gcc3
    make test


Finding files (quickly) from OS X's command line

Using tar

Some basic usage examples of tar.

Archive a set of files:

tar -cvf tarfile.tar /var/log/syslog /var/log/messages

Archive and compress (gzip) a set of files:

tar -cvzf file.tar.gz /var/log/syslog /var/log/messages

Archive and compress (bzip2) a set of files:

tar -cvjf file.tar.bz2 /var/log/syslog /var/log/messages

Extract a tar file:

tar -xvf file.tar
tar -xvzf file.tar.gz
tar -xvjf file.tar.bz2

Display the content of a tar file:

tar -tvf file.tar
tar -tvzf file.tar.gz
tar -tvjf file.tar.bz2


Creating OS X Packages for *nix Programs

Create OS X .pkg files for easily installing custom-built *nix programs.


The "Trick"!!
When installing the Unix programs using make install, set a specific destination for the files. You'll then use that to build your OS X pkg. Example:

DESTDIR=/where/to/temporarily/put/the/stuff sudo make install

On OS X 10.6 (Snow Leopard), had to change the command a bit:

make install DESTDIR=/where/to/temporarily/put/the/stuff


Shell Script Snippets

Useful Bash shell scripts and one-liners for managing files.

Rename multiple files:

for i in *.avi
j=`echo $i | sed 's/find/replace/g'`
mv "$i" "$j"

Can also be written on a single line as

for i in *.avi; do j=`echo $i | sed 's/find/replace/g'`; mv "$i" "$j"; done

Finding Multiple Files in a directory
Find and count how many files were modified more than 365 days ago:

find . -mtime +356 | wc -l

Find and delete files that were modified more than 365 days ago:

find . -mtime +365 -exec rm {} \;



Subscribe to Production Monkeys RSS

Recent Updates

  • 2 years 1 month ago
  • 2 years 1 month ago
  • 2 years 1 month ago
    php 8.x
  • 2 years 2 months ago
  • 2 years 2 months ago
    Drop Centos 5/6 stuff