Select Page

Run tcpdump for a given time using timeout

Lately I needed to run tcpdump on several servers for a given time, and then download the pcap fiels, all in a programmatic way.

So I got to know the useful timeout command, simple and straight-forward.

timeout 120s tcpdump -s 0 -A dst port 80

Remember that if you are not running as root and using sudo, you will need to put sudo before the timeout command, so it can actually send the SIGTERM without getting Permission denied.

sudo timeout 120s tcpdump -s 0 -A dst port 80

If you want to learn more about timeout:
https://explainshell.com/explain?cmd=timeout+120s+tcpdump+-s+0+-A+dst+port+80

Bash A to Z and 0 to 9

When you run a bash command, e.g. grep, and you need to take in account the letters A to Z and 0 to 9, you can use the following syntax:

for i in {{a..z},{A..Z},{0..9}}; do echo $i; done

From here you can take it further.

It came in hand when I was searching for a value in the session directory and the grep could not accept the * value because there were too many files, so I ran this:

for i in {{a..z},{0..9}}; do grep "something" sess_$i*; done

And I got my results as expected.

Installing ODBTP on Linux with PHP 5.4

Hi,
Lately I encountered several opportunities to try and install the ODBTP library, at first I was working on new systems, so when i encountered errors when simply doing pecl install odbtp I tried installing from source, encountering errors during the make command I came to my senses and managed just fine using the basic MSSQL library in PHP.
Then a few weeks ago I needed to upgrade an existing system relying on ODBTP with tight coupling, so i had no choice but to find a way to overcome the errors.
After research on the Internet I came to solution but had no time to document the final solution, until today when I installed a test zone on a separate system and remembered only vaguely what I was looking for.
Follow the instructions here except for this: After moving the php/ext content, patch the php_odbtp.c file using the attached file.
Sources:
This patch was checked on Gentoo linux, Ubuntu server 12.04.1 and Linux mint 14, the variable as far that I could gather from the complaints is the PHP version.