How to tar a list of files

Posted: 29th March 2010 by fabio in bash, linux
Tags: , , ,

If you want to tar a multiple files you must write a file containing a list of file to backup and the use this command:
cat listoffiles.txt | xargs tar czvf yourbackupname.tgz - or
tar zcvf yourbackupname.tgz $(cat listoffiles.txt)

  • Facebook
  • Technotizie
  • Plaxo Pulse
  • LinkedIn
  • Twitter
  • WordPress
  • Google Bookmarks
  • Google Reader
  • StumbleUpon
  • Technorati Favorites
  • Share/Bookmark

Setup NAT on Mac OS X

Posted: 22nd March 2010 by fabio in mac os x
Tags: ,

$ sudo sysctl -w net.inet.ip.forwarding=1
$ sudo natd -interface en1
$ sudo ipfw add divert natd ip from any to any via en1

  • Facebook
  • Technotizie
  • Plaxo Pulse
  • LinkedIn
  • Twitter
  • WordPress
  • Google Bookmarks
  • Google Reader
  • StumbleUpon
  • Technorati Favorites
  • Share/Bookmark

How to ping from php

Posted: 1st February 2010 by fabio in php
Tags: , ,

< ?php
  function ping($host) {
    exec(sprintf('ping -c 1 -W 5 %s', escapeshellarg($host)), $res, $rval);
    return $rval === 0;
  }

  $hosts_to_ping = array('127.0.0.1');
?>
< ?php foreach ($hosts_to_ping as $host): ?>
    < ?php echo $host; ?>
    < ?php $up = ping($host); ?>
    < ?php echo $up ? 'on' : 'off'; ?>
< ?php endforeach; ?>

  • Facebook
  • Technotizie
  • Plaxo Pulse
  • LinkedIn
  • Twitter
  • WordPress
  • Google Bookmarks
  • Google Reader
  • StumbleUpon
  • Technorati Favorites
  • Share/Bookmark

If you want to verify if there are sip channels that are connected for a long period, use this script

#!/bin/bash
###########################################################
# this script chech if channel has reached limit duration
###########################################################

COUNT=`asterisk -rx "show channels verbose" |grep -v "hannel|active" |grep ^SIP |awk '{print $1" "$9}' |wc -l`
`asterisk -rx "show channels verbose" |grep -v "hannel|active" |grep ^SIP |awk '{print $1" "$9}' > /tmp/list_channel`
XLIMIT=50

IFS=$'n'
#echo "Total active calls: " $COUNT
for LINE in $( cat /tmp/list_channel ); do
        CHAN=`echo $LINE | awk '{print $1}' `
        TIME=`echo $LINE | awk '{print $2}' `
        XTIME=`echo $LINE | awk '{print $2}' | awk -F: '{print $2}' `
        if [ $XTIME -gt $XLIMIT ]
        then
                echo "limit reached: " $TIME
                echo "CHAN: " $CHAN;
                echo "TIME: " $TIME;
                #echo "Hangupping call ..."
                #asterisk -rx "soft hangup $CHAN"
        fi
done

  • Facebook
  • Technotizie
  • Plaxo Pulse
  • LinkedIn
  • Twitter
  • WordPress
  • Google Bookmarks
  • Google Reader
  • StumbleUpon
  • Technorati Favorites
  • Share/Bookmark

How to flush your dns cache in mac os x

Posted: 19th November 2009 by fabio in mac os, shell
Tags: , ,

If you want to flush your dns cache on mac os x your must open Terminal and type

dscacheutil -flushcache

  • Facebook
  • Technotizie
  • Plaxo Pulse
  • LinkedIn
  • Twitter
  • WordPress
  • Google Bookmarks
  • Google Reader
  • StumbleUpon
  • Technorati Favorites
  • Share/Bookmark