Archive for June, 2006

Combine PDFs

Tuesday, June 27th, 2006

Try the following Gostscript one-liner:

$ gs -q -sPAPERSIZE=a4 -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=combined.pdf article1.pdf article2.pdf notes.pdf

Typo3update

Sunday, June 25th, 2006

Typo3update is designed to directly update content to a Typo3 website from the command line. It works as a network service and can be used from any machine that can connect to the server running the Typo3 website. For example, quota overviews and cluster news information that is available from command line programs or text files can be updated to Typo3 using simple bash scripts. Typo3update takes the actual content from standard input. Additionally, it requies two command line options: uid and the header.
Have a look at the following example:

$ cat textfile | typo3update 9533 "About"

This will insert the contents of textfile into content element 9533 that has the heading “About”. The heading parameter is to double check the content element id. If the id doesn’t match the supplied heading, typo3update refuses to update (overwrite) the content. Instead, it writes a line to an error log file.
The content element should be created first from the Typo3 backend. To identify the uid of the content element in a certain page, just hover your mouse pointer above the content element icon. The uid will show up in a tool-tip:
Typo3 uid
(more…)

Redirecting stdout & stderr notes

Sunday, June 25th, 2006

Redirect stdout to stderr:

$ echo Oops, something went wrong >&2

Redirect stderr to /dev/null:

$ ls /home /qwerty 2> /dev/null
home:joe john

To get rid off all output:

$ ls /home /qwerty >/dev/null 2>/dev/null
# or
$ ls /home /qwerty >/dev/null 2>&1

Tar over ssh

Saturday, June 24th, 2006

Just a very short note. It’s not so difficult, but I keep on forgetting the syntax. Here it is:

me@localhost$ tar cf - . | \
    ssh user@otherhost 'cd dir; tar xf -'

Need a ‘unit converter’ ?

Wednesday, June 21st, 2006

Answer: Try units. This is an example of a terminal session using units:


$ units
2084 units, 71 prefixes, 32 nonlinear units
You have: 2 inch
You want: mm
* 50.8
/ 0.019685039
You have:

Type help for some help, press ^D to quit units.
Example of usage in a shell script:


# determine installed RAM
kbram=`cat /proc/meminfo | awk '/MemTotal/ { print $2 }'`
gbram=`units "${kbram} kilobytes" 'gigabytes' |sed --silent -e '1p' | awk '{print $2}'`
echo This computer has $gbram Gb of RAM installed!

More info: www.gnu.org/software/units/manual/units.html

Related nerd note: Eenheden toevoegen aan de ‘Unit Converter’ widget.

Alienscan

Wednesday, June 14th, 2006

Today, I wrote a little bash scripts that scans the network for computers that are not registered in DNS. Reverse DNS to be more precise. It uses nmap to do a reverse DNS lookup for each computer it pings:

$ nmap -sPR -oG - 192.168.0.*

The result is filtered for failed DNS lookups:

$ nmap -sPR -oG - 192.168.0.* | grep "()"

Since all computers are contacted their mac address is known in the ARP (Address Resolution Protocol) table:

$ /sbin/arp | grep -w 192.168.0.35 | awk '{ print $3 }'

After looking up the MAC address, a table is presented with ip addresses and their mac addresses. This is the complete script.

E-Tech Wireless USB Adapter & Linux

Saturday, June 3rd, 2006

I just got my E-Tech Wireless USB Adapter working under Ubuntu. These where the steps:

  • Plug the device into the usb port
  • Type ‘dmesg’, this shows the following:

  • [4302473.979000] usb 1-2: new full speed USB device using uhci_hcd and address 4[4302474.383000] usb 1-2: Failed to load zd1201.fw firmware file!
    [4302474.383000] usb 1-2: Make sure the hotplug firmware loader is installed.
    [4302474.383000] usb 1-2: Goto http://linux-lc100020.sourceforge.net for more info

  • Go to the Linux ZyDAS zd1201 Driver website and download the latest firmware driver.
  • Unpack the driver:

  • ~/src$ tar xzvf zd1201-0.14-fw.tar.gz
    zd1201-0.14-fw/
    zd1201-0.14-fw/zd1201.fw
    zd1201-0.14-fw/README
    zd1201-0.14-fw/makefile
    zd1201-0.14-fw/zd1201-ap.fw

    Run ’sudo make install’ in the zd1201-0.14-fw directory. This returned the following error message:

    ~/src/zd1201-0.14-fw$ sudo make install
    INSTALL zd1201.fw zd1201-ap.fw
    Failed: No firmware directory found
    make: *** [install] Error 1

  • So let’s do it ourselves! The command to copy the firmware drivers to the right location is:

  • ~/src/zd1201-0.14-fw$ sudo cp *fw /lib/firmware/`uname -r`

  • Now that the drivers are in place, just pull out the usb stick and plug it in again. In ‘dmesg’ the following section appears:

  • [4303176.729000] usb 1-2: new full speed USB device using uhci_hcd and address 5[4303177.421000] usb 1-2: wlan0: ZD1201 USB Wireless interface
    [4303188.374000] wlan0: no IPv6 routers present

  • Now you can simply configure the new network device using the ‘Networking’ configuration tool which you can find in the ‘System > Administration’ menu.

E-Tech Wireless USB Adapter