Pages

Your Ad Here

This Blog is not to read or go through

because, I have never been such a mess


Search the blog instead

Showing posts with label bash shell. Show all posts
Showing posts with label bash shell. Show all posts

Wednesday, May 25, 2011

SSH Socks Proxy


$ssh -D 9999 username@ip-address-of-ssh-server


Listens to Port 9999 and tunnels the connection via the ssh-server connected

Friday, July 16, 2010

VIM Editor - Search and Replace

  • /searchkey - search something
  • :[range]s/search/replace/ - replace something within range
  • :8,10 s/search/replace/g  - replace something within range
  • :%s/search/replace/g - replace something full document
  • :%s/search/replace/gc.  - prompt

Wednesday, June 23, 2010

Kannel restart script | Attempting to Kill a process in linux until it gets killed

Restarting kannel wasn't simpler, as the bearerbox was not exiting on single stop command for Kannel. So needed to do some tricks on killing the bearerbox first. See the code

#!/bin/bash
while [ true ]
do
 echo "quering bearerbox"
 sleep 1
 count=$(ps -C "bearerbox" | wc -l)
 echo $count
 if [ $count -eq 2 ]
 then
  echo "attempting to kill bearerbox"
  killall bearerbox
 else
  sleep 1
  echo "======= bearerbox killed ========"
  break
 fi
done
sleep 1
bearerbox /etc/kannel/kannel.conf
smsfox /etc/kannel/kannel.conf

Tuesday, April 20, 2010

bash shell quick tips

some quick tips on bash shell programming

a) Variable set/access
varname='some text'
echo $varname
b) store command output to a variable
varname=`somecommand`
echo $varname

or,
an alternate way to do it
varname=$(some command)
echo $varname
eg. - to store current timestamp in a variable
current_timestamp=`date +%s`
echo $current_timestamp
c)s
eg
d)
eg
e)
eg
f)
eg
g)
eg
Your Ad Here