Tool of the week – iptstate

Valic —  December 7, 2010 — Leave a comment

I recently came across this neat tool called IP Tables State or in short iptstate. It basically works like top but displays the network stat in real-time. It also has the ability to delete/remove an entry from the stat table.

This tool can be very helpful in troubleshooting or simply analyzing your stat table by sorting and filtering the table in several different ways such as by protocol or service.

Screen:

iptstate

Wine 1.3.8 Released

Valic —  December 2, 2010 — Leave a comment

The Wine development release 1.3.8 is now available.

Whats new in this release:

  • Icons in the “open with” menus.
  • Man pages for all installed binaries.
  • Support for schemas in MSXML.
  • Many installer fixes.
  • Translation updates.
  • Various bug fixes.

The source is available now. Binary packages are in the process of being built, and will appear soon at their respective download locations.

Bugs fixed in 1.3.8:

4098  Visual Basic 6 sp6 runtime installer: No progress window shown

6856  Civilization 4 fails to start

8107  Civilization 4 Warlords fails to start due to XML issues

12293  Warhammer 40K: dark crusade – Cursor is not properly drawn

14343  Bigfishgames “Play My Games” Crashes With “Unhandled page fault”

15195  People’s General randomly hangs with err:seh:setup_exception_record nested exception on signal stack

16548  qedit:mediadet.c test is skipped due to renaming a file

16842  Goldwave crashes

16988  Guild Wars – ‘blocky’ graphics

More : wine-reviews

Some SED Commands

Valic —  November 30, 2010 — Leave a comment

Sed is a stream editor. A stream editor is used to perform basic text transformations on an input stream While in some ways similar to an editor which permits scripted edits (such as ed), sed works by making only one pass over the input(s), and is consequently more efficient. But it is sed’s ability to filter text in a pipeline which particularly distinguishes it from other types of editors.

Here are some SED commands used by everyone:

1) Print all the lines between 10 and 20 of a file

sed -n ’10,20p’ <filename>

Similarly, if you want to print from 10 to the end of line you can use: sed -n ’10,$p’ filename

This is especially useful if you are dealing with a large file. Sometimes you just want to extract a sample without opening the entire file.

2) Check your unread Gmail from the command line

curl -u username –silent “https://mail.google.com/mail/feed/atom” | perl -ne ‘print “\t” if /<name>/; print “$2\n” if /<(title|name)>(.*)<\/\1>/;’

Checks the Gmail ATOM feed for your account, parses it and outputs a list of unread messages.

3) To print a specific line from a file

sed -n 5p <file>

You can get one specific line during any procedure. Very interesting to be used when you know what line you want.

4) Remove a line in a text file. Useful to fix “ssh host key change” warnings

sed -i 8d ~/.ssh/known_hosts

5) Recursive search and replace old with new string, inside files

grep -rl oldstring . |xargs sed -i -e ‘s/oldstring/newstring/’

recursively traverse the directory structure from . down, look for string “oldstring” in all files, and replace it with “newstring”, wherever found

also:

grep -rl oldstring . |xargs perl -pi~ -e 's/oldstring/newstring'

Just put this in your ..htaccess file.

// .htaccess HTTP to HTTPS Rewrite Rule
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

In this example, each database will be stored separately and like earlier example we will save all databases and we will have the last 4 copies.

#!/bin/bash
#Simple mySQL backup script for cron – updated version

# Modify the following to suit your environment
export DB_BACKUP=”/home/user/mysql_backup”
export DB_USER=”root”
export DB_PASSWD=”***********”
export DATE=”`date +”%d%b”`”
export MYSQL=”/usr/bin/mysql”
export MYSQLDUMP=”/usr/bin/mysqldump”

# Backup part
echo “mySQL_backup”
echo “———————-”
echo “* Rotating backups…”
rm -rf $DB_BACKUP/04
mv $DB_BACKUP/03 $DB_BACKUP/04
mv $DB_BACKUP/02 $DB_BACKUP/03
mv $DB_BACKUP/01 $DB_BACKUP/02
mkdir $DB_BACKUP/01

cd $DB_BACKUP/ && cd $DB_BACKUP/01
$MYSQL -u $DB_USER –password=$DB_PASSWD -Bse ‘show databases’ |while read m; \
do $MYSQLDUMP -u $DB_USER –password=$DB_PASSWD `echo $m` > `echo $m`.sql;done
bzip2 *sql

echo “* Creating new backup…”
echo “Backup done! `date`” > /tmp/my_report.log

# You can set the script to send you mail when backup it’s finished.
mail -s “MySql Backup report” [email protected] < /tmp/my_report.log
echo "----------------------"
echo "Done"
exit 0

Enjoy