Batch printing

I often upload some pdf files on a server to print them at my faculty. On the server I follow these steps:

1. Convert the uploaded pdf files to postscript

for file in `ls -1`; do pdftops $file; done

ls -11 lists all the files of the current directory, one file per line. pdftops actually converts the pdf files to postscript.

2. Delete the pdf files

rm *.pdf

We need to delete the pdf files to only list postscript files in the next command.

3. Put two pages on one page and print them

for file in `ls -1`; do psnup -2 -d0 $file | lpr -Pscit32411d; done

Again we walk through the file list but this time psnup prints two pages on one page and we pipe its result to the print command lpr. The argument P is the printer name of our destination.

I’m sure this can be done in only one line but I’m not a big shell scripter so I make the batch printing in three lines.

  1. The parameter is a one and not a l
  • Delicious
  • Digg
  • Technorati Favorites
  • Reddit
  • LinkedIn
  • Facebook
  • Spurl
  • Twitter
  • Webnews
  • YiGG
  • MySpace
  • Yahoo Bookmarks
  • FriendFeed
  • Google Bookmarks
  • LiveJournal
  • Share/Bookmark

Change permantly Terminal’s style for new windows

I have configured Terminal’s style as Homebrew but it’s only used for the first window if Terminal is launched. If I type the shortcut Command+N the new window has the basic style which I don’t like, it’s just white so not really stylish. I knew that defaults exist to modify an application’s settings using a shell.

defaults read com.apple.Terminal

If you type this in your shell you get the settings set for your application, in my case for Terminal. I was interested in the entry “Default Window Settings”. The value of this key was Basic though I have explicity set it to Homebrew in the configuration panel.

defaults write com.apple.Terminal "Default Window Settings" Homebrew

This line affects the style permantly. Restart Terminal to read the new settings and enjoy the new style.

  • Delicious
  • Digg
  • Technorati Favorites
  • Reddit
  • LinkedIn
  • Facebook
  • Spurl
  • Twitter
  • Webnews
  • YiGG
  • MySpace
  • Yahoo Bookmarks
  • FriendFeed
  • Google Bookmarks
  • LiveJournal
  • Share/Bookmark

Useful Mac commands

From time to time I need to change some configurations or I need a command that I used a long time ago. Because I don’t execute these commands all time I forget them very soon. That’s why I’ll post them here.

Show hidden files in Finder

By default Finder doesn’t show hidden files and there’s no way to change it in the preferences. You have to execute this in your shell:

defaults write com.apple.finder AppleShowAllFiles TRUE # show hidden files
killall Finder                                         # restart Finder

(Un) Installing program packages (.mpkg | .pkg)

Sometimes I want to know first what files are going to be installed. With pax I can take a look at the file list. To be sure to have completely uninstalled an application you can check it by using lsbom.

pax -z -f <Package.pkg/Contents/archive.pax.gz>  # List files that will be installed in the system
lsbom <Package.pkg/Contens/archive.bom>          # List all files that should be removed to uninstall the package

MySQL

I had trouble with phpMyAdmin loading a dump file. I found out that it’s a common problem that it get stuck on a Mac machine. So I had to do it in the shell by using the following line. Further details about the command can be found on the man page.

mysql --user=user_name --password=your_password db_name < dump_file.sql

Re-indexing folders or volumes

If you need to re-index folders or volumes you can do this with mdutil. Sometimes the index is damaged and therefore you have to delete .Spotlight-V100 first. You need the required root permission so sudo is prefixed.

sudo rm -r /Volumes/<Volumename>/.Spotlight-V100
sudo mdutil -E /Volumes/<Volumename>

Get CPU information of your machine

sysctl -a | grep -i "dep.cpu"

I used this command to find out if my cpu supports vtx. And it does :)

Printing

For multiple page printing I use mpage and psbind (a smarter psnup).

mpage -2f -Pokiprinter textfile
mpage -2f -Pokiprinter textfile.ps

okiprinter is the name of my Oki printer ;-)

To print a header and page numbers genscript is useful.

Generating a GUID

A GUID (Global Unique ID), also known as UUID (Universally Unique ID), can be generated by uuidgen which should be installed by default by your Linux or Mac OS.

uuidgen

A unique ID is created using your MAC address amongst others. It looks like 8AF8EEEC-3472-48B0-A74B-B2B3820EA6FE.

  • Delicious
  • Digg
  • Technorati Favorites
  • Reddit
  • LinkedIn
  • Facebook
  • Spurl
  • Twitter
  • Webnews
  • YiGG
  • MySpace
  • Yahoo Bookmarks
  • FriendFeed
  • Google Bookmarks
  • LiveJournal
  • Share/Bookmark