Monday, August 31, 2009

Linux mail basics

# Start interactive mail
mail

# Print current message
p

# Delete current message
d

#Exit mail program
q

Friday, August 28, 2009

Leopard user template

sudo mv /System/Library/User\ Template/English.lproj /System/Library/User\ Template/English.lproj.old

This will give you copy of the original called "English.lproj.old" in the same folder. Then you may copy your new template file by executing:

sudo cp -R /Users/new-user-short-name /System/Library/User\ Template/English.lproj

If you prefer to remove (delete) the original try the command without the /* at the end: sudo rm -r /System/Library/User\ Template/English.lproj

Get mac address from xml and generate computer names for each mac

Parsing xml is pretty easy using grep. The benefit of sed/grep is that they are right there -- if you have cygwin, Linux or Mac.

Here is an example format:



<macs>

<string>00-00-00-00-00-01</string>
<string>00-00-00-00-00-02</string>
</macs>


This will parse the xml file formatted like above and generate a computer name for each mac address. A good application of sed/grep/bash. If you are installing a lot of new computers and need to associate new names with mac addresses, this is a good start.


grep All\ Computers.plist | sed -e 's/<\/*string>//g' | while read line; do ((i++)); echo "pc-$i $line"; done > macs.txt

Friday, August 21, 2009

Set the default printer from the registry

rem Using reg.exe you can set the default printer

@echo off

rem Here we are doing a split of the hostname on the hypen, so room1-01, becomes room1

for /F "tokens=1 delims=-" %%a in ('hostname') do set name=%%a


if %name% == room1 ( reg add "hkcu\software\microsoft\windows nt\currentversion\windows" /t REG_SZ /d "ROOM1PRINTER,winspool,NE04:" /v "Device" /f
)

Thursday, August 20, 2009

Installing a folder tree of fonts on XP

rem XP doesn't let you select a folder to install fonts from; it will not recurse to find fonts within a folder unless they are all under one folder

rem This command will go through all folders in the current directory and copy the files to all_fonts

rem The /y for copy will force an overwrite if a duplicate file shows up

for /F "tokens=1 delims=," %a in ('dir /s /b') do copy /y "%a" all_fonts

Tuesday, August 4, 2009

mysql -- attaching to a host

#This is a way checking your connection to a mysql db server

mysql --user=username -h hostname -p