preload
Nov 18

The situation is as follows. You want to search recursive for a text pattern inside of each files in the directory /var/www/vhosts. Take e.g. the pattern ‘DataStructure’.

Normally you would think about the find-command and executing another command but grep itself can do the job.

grep -RHl -e ‘DataStructure’ /srv/www/vhosts

This command lists all filenames containing the text ‘DataStructure’

Tagged with:
Nov 16

To list all open connections on the actual linux or mac just type the following:

lsof -i

For faster lookup without replacing IP through DNS-lookup:

lsof -i -n

Try also with root-permission for more files:

sudo lsof -i -n

Now you can easily spot programs connecting to the internet an dump the tcp-data with tcpdump.

For example dumping data from tcp-port 80 to a file called test.pcap:

tcpdump -w test.pcap tcp port 80

Now show the file:

tcpdump -nnr test.pcap

or

tcpdump -ttttnnr test.pcap

for timestamp information

Tagged with:
Nov 10

Normally it is not ab problem to convert a CMYK picture to a RGB picture with Photoshop. But what do you do if you have e.g. thousands of high quality pictures, and you want to convert these so RGB? With Linux you can easily convert your files.

All you need is

  • ImageMagick
  • RGB Color profile e.g. ColorMatchRGB.icc or AdobeRGB1998.icc
  • CMYK Color profile e.g. USWebCoatedSWOP.icc (can be downloaded on adobe website)

Installing ImageMagick and downloading the color profiles can not be explained here.

Now to convert picture called cmyk.jpg to rgb simply enter the following command:

convert -profile /pfad/zum/profil/USWebCoatedSWOP.icc \ -profile /pfad/zum/profil/ColorMatchRGB.icc cmyk.jpg rgb.jpg

For not writing the the whole line for each file create a bash-script:

#!/bin/bash

cmyk_profile=”/pfad/zum/profil/USWebCoatedSWOP.icc”

rgb_profile=”/pfad/zum/profil/ColorMatchRGB.icc”

ifile=”$1″ ofile=`basename “$ifile” .jpg`”_rgb.jpg”

convert -profile “$cmyk_profile” -profile “$rgb_profile” “$ifile” “$ofile”

Save this script as cmyk2rgb.sh and make it executeable with

chmod +x cmyk2rgb.sh

Now you can call this via:

./cmxk2rgb.sh bild.jpg

And a file called bild_rbb.jpg will be created.

Now other fine things are possible like find all files with ending .jpg and convert them to rgb:

  for i in *jpg;
  do
    ./cmyk2rgb.sh "$i";
  done
Tagged with:
Nov 10

Damit man eine E-Mail mit den entsprechenden Diffs der Quellcodeänderung bekommt muss man lediglich folgende Zeilen in die Subversion-Datei hooks/post-commit im entsprechenden Projekt hinzufügen:

/usr/local/bin/svnnotify                    \
–repos-path    “$REPOS”                \
–revision      “$REV”                  \
–subject-cx                            \
–with-diff                             \
–handler       HTML::ColorDiff         \
–to            my@mail.com   \
–from          myfrom@mail.com

Um jetzt einen sogenannten post-commit-hook zu trac zu erzeugen, trägt man in der selbigen Datei noch folgendes ein:

/usr/bin/python /usr/local/bin/trac-post-commit-hook -p “$TRAC_ENV” -r “$REV”

Das ermöglicht Kommandos im Subversion Kommentar wie z.B. “fix #3″ um Ticket Nummer 3 zu schließen.

Tagged with: