Fun with shell


For all cricket fans and PC freaks out there , this is delight script both cli and gui scripts are there in the source.  


For cli : Just place the “crick” file in /bin with chmod +x and run crick command from anywhere in terminal to see the score card. 


For GUI : Extract the file “crick-info-gui.tar.gz” from the source and cat README.


To download :source {click}

Use this to format any media , including your HDD , pen drives , usb portables , memory cards and so on.Please note : Be careful while selecting the /dev/sd* in the list menu.
Tired this as there was a need to right click format on Ubuntu : Download here

Just came across a tool called “mtr” , it expands to “My trace Route”

DESCRIPTION
mtr combines the functionality of the traceroute and ping programs in single network diagnostic tool.
 
As  mtr starts, it investigates the network connection between the host mtr runs on and HOSTNAME.  by sending packets with purposly  low  TTLs.
     
It  continues to send packets with low TTL, noting the response time of the intervening routers.  This allows mtr to print  the  response  percentage and response times of the internet route to HOSTNAME.  A sudden increase in packetloss or response time is often an indication of a bad(or simply overloaded) link.
To install : mtr {click}
After installing just , type in “mtr” in terminal to run and see the o/p for your local host.
Description:

Have you ever wished you had a right click send-to-media.

This scripts gives options to send files/folders to media that is mounted.

Send to USB , HDD , CD/DVD ROM any media that is mounted !!



I was hungry for something new and tried this , send to usd or any media that is mounted on the machine , have a look at : sendtomeida

 

Description:

Have you ever wished you had a right click send-to-media.

This scripts gives options to send files/folders to media that is mounted.

Send to USB , HDD , CD/DVD ROM any media that is mounted !!



I was hungry for something new and tried this , send to usd or any media that is mounted on the machine , have a look at : sendtomeida

 

Description:

Have you ever wished you had a right click send-to-media.

This scripts gives options to send files/folders to media that is mounted.

Send to USB , HDD , CD/DVD ROM any media that is mounted !!



I was hungry for something new and tried this , send to usd or any media that is mounted on the machine , have a look at : sendtomeida

 

A mysterious virus , had changed the extensions of *.avi to *.jpeg , in on of friends portable harddisk , know the power of Linux , she asked can you write a small code to change the extensions , i gave it a try this way : 



for i in *.jpg; do j=`echo $i | cut -d . -f 1`; j=$j".avi"; mv $i $j; done


Further tried to make it more generic

#!/bin/bash
old=$(zenity --entry --text="Current extension" --title="Rename")
new=$(zenity --entry --text="New extension or name" --title="Rename")
for i in *.$old; do j=`echo $i | cut -d . -f 1`; j=$j".$new"; mv $i $j; done
zenity --info --text="Done"

Steps in images :

   Inspired by Scott’s FAST database implemented as a batch file and hasan.diwan@gmail.com bash script , i tired a bit more on it , it’s as below :


#!/bin/bash


fad()
{
echo “$1″ >> ~/.db
echo “Updated at $@”
}


f()
{
grep “$1″ ~/.db
}


fuse()
{
echo “f keyword to search”
echo “f -add or f -a to add “
}


case “$1″ in


-a |-add |–add) fad “$2″
;;

“”) f “$*”
;;

*) fuse
;;


esac

For the input either use bash’s tab completion, which will automatically put in backslashes as appropriate, or the user should quote it.

Sample :

To add
$ f -a “hemanth.hm nerd +919449167054″
$


To search
$ f “nerd”
$ hemanth.hm nerd +919449167054

My sensiour thanks to  \amethyst and greycat , for teaching me best partices :)


To run the script as a command , place the script in /bin.



More graphical approach

                                                                                              

#! /bin/bash

fad()                        
{
echo “$1″ >> ~/.db
notify-send “Database Updated $@”
}

f()
{
res=$(grep “$1″ ~/.db)
echo “$res”
notify-send “$res”
echo “$res” | zenity –text-info
}

fuse()
{
echo “f keyword to search”
echo “f -add or f -a to add “
}

case “$1″ in

-a |-add |–add) fad “$2″
;;

“”) f “$*”
;;


*) fuse
;;

esac
Just  wonder  why not you tweet while coding from terminal , so tired this :
#! /bin/sh

user=”twitter-username”
password=”twitter-password”

echo “You want to tweet about ?”
read message 
curl -u  $user:$password -d “status=$message” “https://twitter.com/statuses/update.xml”

Rather disadvantage if your friend could read your script right ;)
So tired this :

__________________________________________________________________________________

#! /bin/bash
tweet()
{
usr=$(zenity –entry –text=”Username” –title=”Twitt”)
pwd=$(zenity –entry –text=”Password” –title=”Twitt” –hide-text)
msg=$(zenity –entry –text=”Tweet” –title=”Twitt”)

if [ "$usr" = "" ]; then
zenity –info –text=”UserName invalid”
tweet
elif [ "$pwd" = "" ]; then
zenity –info –text=”Invalid Password”
tweet
elif [ "$msg" = "" ]; then
msg=”www.h3manth.com”
fi
}

tweet
URL=”https://twitter.com/statuses/update.xml”
curl -u ${usr}:${pwd} -d status=”${msg}” ${URL} -k -s > /dev/null

if [[ $? = 0 ]];
then
zenity –error –text=”You couldn’t twitt , check if everything is fine ” –title=”Twitt”
exit 0
else
zenity –info –text=”$msg is twitted” –title=”Twitt”
exit 1
fi

__________________________________________________________________________________

Join hands :  twitty

One of my firends wanted this , so i explained him stepwise how to do it , then thought why not a script , here it is :
===================================================
#! /bin/bash
ZENITY=/usr/bin/zenity

if hash zenity 2>/dev/null; then

if hash mogrify 2>/dev/null; then

loc=$(${ZENITY} –file-selection –title=”Select a File” –directory)
cd $loc
pwd
mkdir resized
cp $loc/* $loc/rz/
cd rz

size=$(zenity –title “Give the required resize value” –entry –text “Resize value”)
type=$(zenity –title “Give the file type you want to resize ” –entry –text “File type”)

mogrify -resize $size! *.$type | ( zenity –width=400 –height=100 –progress –title=”Please wait ” –text=”…….” –percentage=0)

zenity –info –text=”Operation completed”

else

echo “Installing the dependcies”
sudo apt-get install imagemagick
sudo apt-get install zenity
exit 0;
fi
fi
===================================================
Steps in images :

Next Page »