These are a bunch of notes of various things which are easily forgotten or whatnot. Stuff to keep handy for macosx (darwin) and linux commands and examples which may or may not be useful. Use at your own risk. Your mileage may vary. Watch out for line breaks. Oh, also, Applescript.

now also gimp-print and lpr

and connecting pulse oximeter to linux machine

plus os x screen grab via web on demand

e2fsprogs build error

lvm command lvremove hangs on kernel 2.6.15 and later

Linux NETDEV WATCHDOG ethernet transmit error

mime types for 3g2, 3gp, video from cellphones

stop activation dialog and delay with netscape 6 on os9

use php to generate a time based uuid or guid

NetXtreme II BCM5708 Gigabit Ethernet won't work with bridging in xen debian etch kernel 2.6.18-6

Exporting Quickbooks Bills to excel tab separated text, converting to iif on mac os x with applescript for importing into Quickbooks

Exporting HDV video from Final Cut Pro using Compressor 2 for uploading to youtube

error compiling gphoto2 2.4.8 on Mac OS X 10.6

install libjbig jbigkit on mac os x

Export all note, appointment, call data for Now Contact to Apple Address Book compatible vcf file

A possible fix when iPhoto and Image Capture fail to download photos from an iPhone

getting gnuplot to link only to libpng 1.5 instead of both 1.2 and 1.5 in Mac OS X

Using photopc with old Toshiba laptop and Nikon camera for time lapse photos

mplayer on mac os x creates a dock icon every time

opendkim not signing with sendmail using milter-greylist

newsyslog for rotating mac os x apache log files

applescript via command line, osacript, to control Skype video and audio

applescript to kill Skype before it automatically calls back on disconnect

__________

php-4.3.0
'./configure' '--with-apxs=/usr/sbin/apxs' '--with-mysql' '--with-zlib' '--enable-ftp' '--with-jpeg-dir=/usr/lib' '--with-png-dir=/usr/lib' '--with-tiff-dir=/usr/lib' '--with-zlib-dir=/usr/lib' '--with-gd=/usr/local' '--with-ttf' '--with-xml' '--enable-track-vars=yes' '--enable-track-errors=yes' '--enable-magic-quotes=yes' '--enable-exif' '--with-freetype-dir=/usr/lib'


php-4.3.2
'./configure' '--with-apxs=/usr/sbin/apxs' '--with-mysql' '--with-zlib' '--enable-ftp' '--with-jpeg-dir=/usr/lib' '--with-png-dir=/usr/lib' '--with-tiff-dir=/usr/lib' '--with-zlib-dir=/usr/lib' '--with-gd' '--with-ttf' '--with-xml' '--enable-track-vars=yes' '--enable-track-errors=yes' '--enable-magic-quotes=yes' '--enable-exif' '--with-freetype-dir=/usr/lib' '--enable-gd-native-ttf'

(first with built in gd?) (Native TrueType string function  To enable support for native TrueType string function add --enable-gd-native-ttf)??

apache 1.3.27
./configure --with-layout=RedHat \
            --enable-module=most \
            --enable-shared=max


chkconfig
_________
used to add runlevel scripts from /etc/init.d/ scripts with lines added to scripts like:

# chkconfig: 345 55 10
# description:  synchronize the time of a computer client or server to \
# another server.

first set of numbers are runlevels to run in, second number start priority, third number, stop priority
then run something like 'chkconfig thingd reset'

to remove a service 'chkconfig --del rhnsd'
or set the first set of numbers to "-" then reset
________
Mac OS X mod rewrite, make sure these lines are uncommented in httpd.conf
#LoadModule rewrite_module     libexec/httpd/mod_rewrite.so
#AddModule mod_rewrite.c
   then, in the desired user/username.conf
<Directory "/Users/username/Sites/">
    Options Indexes MultiViews SymLinksIfOwnerMatch
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
   and in .htaccess, something like:
RewriteEngine on
RewriteBase /dirfromwhichtobase/
RewriteRule ^([^./]+)/?$ index.php?r=$1
RewriteRule ^x$ phpinfo.php
________
cp whole file system
x - single file system
p - preserve attrbutes
P - parents (full dir path)
d - no dereference (links as links)
R - recursive (special files as special)
cp -xpdPR / /mnt/point/
________
how to tar something like a dir
 tar -c -fmusic.tar practice
 
/usr/bin/gnutar -N '2003-02-10 1:15' --exclude '.DS_Store' -cvf images5.tar IMAGES Previews
[both directories above]
/usr/bin/gnutar -N 2003-01-23 --exclude '.DS_Store' -cf images4.tar IMAGES
/usr/bin/gnutar -N 2003-01-10 --exclude '*.tif' -cf images3.tar IMAGES
put all the files in the dir IMAGES which are newer than jan 10, excluding anything ending in tif, into a tar archive called images3.tar
be sure to use gnutar to untar a gnutarred archive
_____
md5 checksum
md5sum filename
if you dont have md5sum, like on os x, then try:
openssl dgst -md5 filename
_____
pgpv sendmail.8.12.8.tar.gz.sig
pgpk -a PGPKEYS
_____
#clear sendmail queue for client verbose
sendmail -Ac -q -v
_____
#alias expansion and determine if the final delivery address is valid, verify, deliverable
sendmail -bv address
_____
bz2 to decompress .bz2 file  (-I option in tar or -j in other versions)
bzip2 -d linux-2.4.18.tar.bz2
_____
set environment stuff
export PATH=$PATH:/usr/local/bin        (in bash or ksh)
set path=($path /usr/local/bin)         (in csh or tcsh)
_____
du -h --max-depth 1 /
_____
echo "bad dir name" | sed 's/[^A-z0-9\-\.]/_/g'
_____
perl -p -i.bak -e 's/\r/\n/g' ~/test33
  another way to translate linebreaks:  tr "\r" "\n" < file1 > file1.xlated
gpg test33
ripmime -i eudB07.tmp
_____
sort -t"|" -k 2 -o filesort -r file2
tr "\n" "\r" < filesort > file3
tr "|" "\t" < file3 > file4
_____
gpg -ea --always-trust -r email@foo.bar -r other@foo.bar
_____
see root level permissions
ls -ld /
_____
scp [-pqrvBC46] user@host:file user@host:file
 -r      Recursively copy entire directories.
_____
ssh-keygen -t rsa
Generating public/private rsa key pair.
add public key to authorized keys, below would replace:
scp .ssh/id_rsa.pub username@domain.com:.ssh/authorized_keys
_____
openssl
./config shared
_____
openssh
after intalling openssl, had to run ldconfig, after adding /usr/local/ssl/lib dir to /etc/ld.so.conf (otherwise header lib mismatch)
./configure --with-tcp-wrappers --with-pam
from contrib/redhat copied sshd startup script to /etc/init.d/ modified to reflect true locations of keys and binaries, worked
also cp sshd.pam /etc/pam.d/sshd
also follow README.privsep
______
# type crontab cronfile to activate
MAILTO="foo@foo.bar"
#53 03 * * * rdate -s ntp.cmr.gov
49 03 * * * rdate -s nist1-dc.glassey.com
_____
gnome config?
vi /usr/share/mime-info/mc.keys (system wide mime open with)
_____
route
route add  default gw 192.168.1.2 dev eth1
_____
/bin/cat /dev/null > filetomakenull
_____
in dir IMAGES delete files not ending in jpg -type f excludes dirs
find IMAGES -type f -regex "^.*/.*[^j][^p][^g]" -delete
find IMAGES -name ".DS_Store" -delete
find php files which contain text pattern:
find ./ -type f -name "*.php3" -exec grep -l searchpattern {} \;
find files owned by one user, change ownership to another
find / -user smith -exec chown smythe "{}" \;
# find files on volume ending in slice or weblge less than one day old, tar them
find /volumes/FWHDExt500gbB -ctime 1 \( -name "*Slice.tif" -or -name "*WebLge.tif" \) -exec tar -vuf tarfile.tar "{}" \;
_____
find files modified on a particular day (10/31/2004), change mod date to 10/30/2004, first expr to find #days, then find
expr \( `date +%s` - `date --date=10/31/2004 +%s` \) / 3600 / 24 
find . -mtime the_result_of_above -exec touch -t 200410300001 {} \;
_____
find and edit files like above, with perl
find ./ -type f -name "*.php*" -exec grep -l mysql.sock {} \; |xargs  perl -pi -e "s/\/var\/lib\/mysql\/mysql.sock/\/tmp\/mysql.sock/g;"
(find: type -f (regular files, not links), grep: -l filenames, xargs: append result to following, perl: -p execute once for each line of input -e command line execute -i in place editing) 
use perl to fix old tail -1 to tail -n 1 style
perl -pi -e "s/tail -1/tail -n 1/g;" src/Configure
 same but searching directories for multiple files
grep -lr "tail -1" * | xargs perl -pi -e "s/tail -1/tail -n 1/g;"
_____
find shared library dependencies
ldd /usr/sbin/httpd
_____
use ssh to connect to a web server on remote lan as if locally
ssh <remote-ip> -L 8000:<remote-server>:80
then use browser to connect
http://localhost:8000
_____
vi set line numbers (and turn off)
:set number
:set nonumber
vi search and replace whole document (% means whole, otherwise, only current line)
:%s/search_string/replacement_string/g
go to line number 138
:138
_____
debian show list of installed packages
dpkg --get-selections
_____
sudo diskutil eraseDisk "Journaled HFS+" BackupHD1A_250gb disk4
#erase disk command line
diskutil reformat /Volumes/BackupHD1A_250gb
#erase disk (need ownership, don't need sudo)
_____
# host is down, want to be notified when it comes back up
ping -a -i 60 subdomain.example.com
-a audible bell when packet received
-i 60 wait 60 seconds between packets
_____
# block an ip with iptables
iptables -I INPUT -s 41.219.209.20 -j DROP
_____
# mac os x show idle time from command line
ioreg -c IOHIDSystem | perl -ane 'if (/Idle/) {$idle=(pop @F)/1000000000; print $idle,"\n"; last}'
_____
build kernel
if patch: decompress patch in /usr/src then cd into linux dir, then 
 patch -p1 < ../patch-2.4.21
download and untar/zip into /usr/src/linux-2.4.18
 make menuconfig
 make dep
 make zImage
 make modules
 make modules modules_install
end up with System.map and vmlinux
copy vmlinux to mac_boot/System Folder/Linux Kernels/
(to use compressed (okay with BootX?): cp arch/ppc/boot/images/miboot.image /mnt/apple/System\ Folder/Linux\ Kernels/vmlinuz-2.4.21)
copy System.map to /boot
 nice to copy System.map-version
 then link to System.map
ln -s System.map-2.4.18 System.map
and not necessary for BootX, but nice to also put vmlinux in /boot and link versionwise
ln -s vmlinux-2.4.18 vmlinux
then reboot and select new kernel
____


____
Volume ID
The data is stored in /var/db/volinfo.database.
sudo /System/Library/FileSystems/hfs.fs/hfs.util -k rdisk1s10 ; echo
425C2AD356EDFD30
____
OS9 OSX
sudo bless -folder9 /Volumes/diskname/'System Folder' -bootBlocks -folder /Volumes/diskname/System/Library/CoreServices -bootinfo /usr/standalone/ppc/bootx.bootinfo -label "diskname"

OSX
sudo bless -folder /Volumes/diskname/System/Library/CoreServices -bootinfo /usr/standalone/ppc/bootx.bootinfo -label "diskname"

OS9
sudo bless -folder9 /Volumes/CLASSIC_HD/'System Folder' -label "CLASSIC_HD" -bootBlocks
____
powermac 7500 linux serial ports: "cua0" (modem port) or "cua1" (printer port) (obsolete, use /dev/ttyS0 /dev/ttyS1)
____
kill `ps ax | grep runner | grep -v grep | awk '{print $1}'`
____
#unmount and spin down external noisy disk
umount /dev/sdc7                
/usr/src/scsi/sbin/scsi-spin -d /dev/sdc
____
Mac OS X command line to mount .dmg disk image:
hdiutil attach DiskImage.dmg
____
be careful with rsync, it does not handle resource forks, so only use it on files which dont have resource forks (ie, won't work on applications, quark documents, etc)
v-verbose r-recursive t-preserve times -e (ssh) u-update only a-archive(preserve time owner etc) n-dry run
rsync -vrtu --exclude='.DS_Store' -e ssh 'username@192.168.1.20:/Documents/Picture\ Databases/Previews/' "/Volumes/PMG4-3Int80gb/Documents/Picture Databases/Previews"
rsync -vrt --exclude='.DS_Store' -e ssh 'username@192.168.1.20:/Documents/Picture\ Databases/IMAGES/' "/Volumes/PMG4-3Int80gb/Documents/Picture Databases/IMAGES"
[add n option to above to do dry runs]
escapes and expansion can be complex for remote machine, using escapes within single quotes, etc.

rsync -v -e ssh 'username@192.168.1.20:/Documents/Picture\ Databases/\*EWS\ MASTER.fdb' "/Volumes/PMG4-3Int80gb/Documents/Picture Databases/*EWS MASTER.fdb"
rsync: open connection using ssh -l ccrumley 68.10.202.179 rsync --server --sender -v . "/Documents/Picture\ Databases/\*EWS\ MASTER.fdb" 
./*EWS MASTER.fdb
wrote 60044 bytes  read 1634042 bytes  25863.91 bytes/sec
total size is 118095872  speedup is 69.71
____
rsync handles resource forks in OS X 10.4 tiger
____
to see the last 99 lines (screen at a time) of a mac line break file in terminal
tr "\r" "\n" < "/Library/Preferences/Retrospect/Operations Log" | tail -99 | more
____
use less and gunzip to view a gzipped text file
gunzip -c /var/log/maillog.0.gz | less
____
patch 2.5.4 never worked on my linux ppc machine
i had to go back to patch 2.5
____
create password file for .htaccess file:
htpasswd -c /etc/.htpasswd William
add name to it:
htpasswd /etc/.htpasswd bob
____
find only lines in common between two files with sorted lists
comm -1 -2 file1 file2
(-1 and -2 suppress the columns 1 and 2 which contain the unique from file 1 and 2)
____
linksys router hidden log page with additional log choices
http://192.168.1.1/LogManage.htm
Access Log
System Log
PPPoE & RAS Log
NAT Log
____
added line: skip-innodb in file /etc/my.cnf
to purge bin logs of mysql: reset master
____
#set volume by command line, mac os x, applescript
osascript -e "set volume output volume 60"
____
#throttle bandwidth for port 80 for testing how slow connections will behave
sudo ipfw pipe 1 config bw 11KByte/s
sudo ipfw add 1 pipe 1 dst-port 80
	00001 pipe 1 ip from any to any dst-port 80
sudo ipfw add 1 pipe 1 src-port 80
	00001 pipe 1 ip from any to any src-port 80
sudo ipfw delete 1

____
#exiftool strip all EXIF data from directory
exiftool -all= directory/path
#set file modification date based on exif
exiftool '-DateTimeOriginal>FileModifyDate' dir
# filename tab description -T is for table
exiftool -T -FileName -Description directory/path
____
# delete all profiles matching keyword -r recursive
exiftool -r -overwrite_original -icc_profile:all= -if '$ProfileDescription=~/SCANPROFILE_3220MFP/' .
____
# use ffmpeg tool ffprobe to get single value about video stream, width, height, duration
# can output in formats like xml, json
ffprobe -v quiet -print_format compact -select_streams v -show_entries stream=width,height videofile.mp4 
stream|width=1920|height=1080
ffprobe  -v quiet -print_format compact -select_streams v -show_entries stream=duration videofile.mov
stream|duration=363.738739
____
#use ifconfig to bring up and down ips
ifconfig eth0:1 up 199.134.158.95 netmask 255.255.255.0
ifconfig eth0:1 down

____
To get a host's base64 encoded key issue the command:
$ ssh-keyscan -t rsa,dsa hostname
Optionally you can specify -H to have the key displayed in the hashed form. -v increases verbosity.
To search for an entry in known_hosts issue:
$ ssh-keygen -H  -F hostname
You can also delete a single entry from known_hosts:
$ ssh-keygen -R hostname
____
ssh (rsync) connect even if host key mismatches or doesn't exist
rsync -av --delete -e 'ssh -o StrictHostKeyChecking=no' username@example.com:Libary/Mail/ ~/Library/Mail
____
command line launch retrospect
sudo /Library/StartupItems/RetroClient/RetroClient
____
#use iconv to convert windows latin 1 text file to utf8
iconv -f WINDOWS-1252 -t UTF-8 filetoconvert > destinationfilepath
____
#command line apple system profiler
system_profiler -detailLevel mini
____
#command line apple installer
sudo /usr/sbin/installer -verbose -pkg php-4.3.6.pkg -target /
____

______________
i had to also install another redhat package, pciutils-devel-2.0-2
This package just contains
/usr/include/pci/pci.h
/usr/include/pci/header.h
/usr/include/pci/config.h
/usr/lib/libpci.a
______________
my system is pretty basic, this is about all it took (done as root) (i have pgp 5, and all the pgp stuff might be different, or unnecessary if you trust md5):

cd /usr/src
wget ftp://ftp.sendmail.org/pub/sendmail/sendmail.8.12.8.tar.gz
wget ftp://ftp.sendmail.org/pub/sendmail/sendmail.8.12.8.tar.gz.sig
ls -latr
pgpv sendmail.8.12.8.tar.gz.sig
wget ftp://ftp.sendmail.org/pub/sendmail/PGPKEYS
pgpk -a PGPKEYS
pgpv sendmail.8.12.8.tar.gz.sig
md5sum sendmail.8.12.8.tar.gz
tar -xzf sendmail.8.12.8.tar.gz
cd sendmail-8.12.8
ls
more INSTALL
cd sendmail
sh Build
cd ../cf/cf
ls
cp submit.mc submit.mc.original
cp generic-linux.mc sendmail.mc
sh Build sendmail.cf
cp /etc/mail/sendmail.cf /etc/mail/sendmail.cf.2003.bkup
sh Build install-cf
cd ../../sendmail
sh Build install
/etc/rc.d/init.d/sendmail restart

________
Mac OS X
Nikon View Monitor Carbon, i wanted to uninstall it
an annoying file which kept running, even after i deleted all Nikon View files
even when it was in the trash
couldn't find it in /Library/StartupItems or Login Items in System Preferences.
Finally found it in /Library/Preferences/loginwindow.plist
it's an AutoLaunchedApplicationDictionary
can be deleted with TextEdit or Property List Editor
____________________
Mac OS X
sudo tmutil associatedisk -a "/Volumes/NewDisk" "/Volumes/BackupDisk/Backups.backupdb/MPro3/Latest/OldDisk"
#change name of disk being backed up with time machine
___________
build stem.so, word stemming extension, for universal install of php5
___________
rsnapshot.conf multiple rsync long arguments

Kurdish Goddess
up