Sunday, April 21, 2013

View Unbilled usage in Airtel Internet


Log on to this website https://ebpp.airtelworld.com/myaccount/

After logging in you need to select you internet account, first click on "My account" > Then drop down > Then select you DSL connection.



Now select on my account


On scrolling down we can see the unbilled usage.  If we need detailed usage, we can still click on "Click here"



Friday, April 19, 2013

Startup script for gnome-terminal



http://www.linuxquestions.org/questions/linux-general-1/run-command-in-new-gnome-terminal-185216/


Open up the start up script here over GUI here.

gnome-session-properties

In that click on ADD and then

1. Give the startup script some name.
2. Give the command as shown

gnome-terminal -x /bin/bash -c "ls"

3. Give what ever comment you want to give and save it.


Next time you login with you credential, a gnome-terminal will pop out of nowhere and it will list all the files.  You can replace the list command with what ever script you want :-D


One more thing I did see the shell which gets spawned getting closed automatically,  In order to prevent that we need to exec bash as shown. Ref(http://stackoverflow.com/questions/3512055/avoid-gnome-terminal-close-after-script-execution)

$ gnome-terminal -e "bash -c \"echo foo; echo bar; exec bash\""


We can also start many sessions in multiple windows with the following command

gnome-terminal --tab --title="Listing" -e "bash -c \"ls; exec bash\"" --tab --title="cat example.txt" -e "bash -c \"cat example.txt; exec bash\""

Thursday, April 18, 2013

Chennai Property Tax


One of my acquaintance wanted to pay property tax online hence approached me for help thinking I can help, well what do you know after a bit of google search I was able to come up with this :-)

http://www.chennaicorporation.gov.in/online-civic-services/ptbillSearch.do?do=getOldLoad

With this link you can enter old data get new

Zone Number:
Ward Number:
Bill No:
Sub No:



Sunday, April 14, 2013

Get page numbers of PDF files

This small script would list all PDF files in a folder along with the number of pages in each one of them.

a.py is nothing by the pdfid python script.


#!/bin/bash
for f in *.pdf
    do
    #echo $f
    pagenumber=`/usr/bin/a.py "$f" | grep "Page" | cut -de -f2`
    echo "$f    $pagenumber"
done

1.pdf                 5
2.pdf                 6
3.pdf                 7
4.pdf                 8
 

Tuesday, February 19, 2013

Get a chunk of PCAP from a larger PCAP

One way of extracting pcap within a time constrain.
 
#editcap -A "2013-02-19 05:19:00" -B "2013-02-19 05:21:00" Input.pcap output.pcap



Second method

wireshark -r input.tcpdump -w output.tcpdump -R 'frame.time >=  "Aug 15, 1990 00:00:00" && frame.time <= "Aug 15, 1990 00:01:00" 



Thursday, February 7, 2013

SSH client predefine your Source Port

Hi

I was actually searching to see how I can set my source port to be of some fixed value while SSHing to a server,  I found the way in this link

http://www.linuxforums.org/forum/security/182001-how-do-i-specify-source-port-ssh-client.html

 These are all that you would be require to do.

# ncat -l 2222 --sh-exec "ncat SSH_SERVER_IP 22 -p 443"


From another terminal you can see that port 2222 is listening on my system locally

# netstat -antulp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      847/cupsd      
tcp        0      0 0.0.0.0:2222            0.0.0.0:*               LISTEN      13219/ncat    

Form another terminal I tried to ssh to my local machine port 2222.

$ ssh bala@localhost -p 2222
bala@localhost's password:
Linux SSH_SERVER_IP 2.6.32-5

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.

bala@SSH_SERVER_IP:~$ exit
logout
Connection to localhost closed.
bala@bala-desktop:~$

Before I closed the connection shown above, I did this command from another terminal, which clearly shows that my source port to be 443.

bala@bala-desktop:~$ ss | grep 22
ESTAB      0      0               10.0.2.15:https        SSH_SERVER_IP:22

Sunday, November 25, 2012

Bash Scripting examples

Example1:
This shows the usage of single quote and double quote.

#!/bin/bash
test="bla bla bla bla";
echo 'I read a sentence like $test inside double quotes';
echo "I read a sentence like $test inside double quotes";
apple='$test'; #Single quotes takes it as a literals
banana=\$test; #Backslash does the same thing
MYIP=`ifconfig eth0 | grep inet | cut -d: -f2 | cut -d" " -f1`;
echo "My IP address is $MYIP";


Example2:
This shows the if condition operation.

#!/bin/bash
fruit1="apple";
fruit2="banana";
if [ $fruit1 != $fruit2 ]
then
   echo "$fruit1 is not equal to $fruit2";
else
   echo "$fruit1 is equal to $fruit2";
fi
# -n is for non empty & -z is for zero length
if [ -n $fruit1 ]
then
   echo "Fruit1 is not the empty string";
else
   echo "Fruit1 is an empty string";
fi

Example3:
#!/bin/bash
# -eq equal, -ne notequal
# -gt (greater than), -ge (greater than or = 2)
# -lt (less that), -le (less than or = 2)
num1=5;
num2=10;
num3=15;
if [ $num1 -ge $num2 ]
then
   echo "$num1 is greater than or equal to $num2";
else
   echo "$num1 is less than $num2";
fi
let num4=$num1+$num2;
if [ $num4 -eq $num3 ]
then
   echo "$num4 is equal to $num3";
else
   echo "$num4 is not equal to $num3";
fi

Example4:
#!/bin/bash
# -r is read permission set, -w for write, -x for execute
# -d (is the file a directory), -f for file, -s non-empty file
dir1=/home/bala;
file1=/tmp/script.sh;
if [ -d $file1 ]
then
   echo "$file1 is a directory";
else
   echo "$file1 is not a directory";
fi
if [ -x $file1 ]
then
   echo "$file1 is executable";
else
   echo "$file1 is not executable";
fi
if [ -r $dir1 -a -x $dir1 ]
then
   echo "$file1 is readable N executable";
else
   echo "$file1 is not both read & executable";
fi

Example5:
#!/bin/bash
#This script is going to loop into useraccount
passFile=/etc/passwd
userCount=0;
specialCount=0;

userIds=`cat $passFile | cut -d: -f3`;
echo $userIds;
for id in $userIds
do
    if [ $id -ge 1000 ]
        then
            echo $id
            #echo $userCount
            let userCount=userCount+1;
            #echo $userCount
        else
            #echo $specialCount
            let specialCount=specialCount+1;
    fi
done
echo "There are $userCount normal users and $specialCount special users on the system"