bash script with sql to get the number of records from multiple tables.

2010-02-10 1 min read Bash Database Learning Linux Solaris

Here is the bash script:

#!/bin/sh
names[1]=errorlog
names[2]=amit1log
names[3]=amit2log
names[4]=amit3log
names[5]=amit4log
j=1
echo $1
for i in $( sqlplus amit/passwd@tns @get_count.sql |sed  -n ’/COUNT/,/Disconnected/p’|sed ’/COUNT/ d’|sed ’/—/ d’|sed ’/Disconnected/ d’|tr ’n’ ’ ’  )
do
temp=${names[$j]}
let count=30-${#temp}
for ((I=1; I <= $count ; I++))
do
printf &#8221; &#8221;
done
echo  &#8221;${names[$j]}    : $i&#8221;
# echo $j
let j=j+1
done
echo
echo

and the required sql script:

select count() from errorlog;
select count(
) from amit1log;
select count() from amit2log;
select count(
) from amit3log;
select count(*) from amit4log;
quit;

Continue reading

How To Build A Self-hosted WordPress Blog For Free

2010-02-04 1 min read Linux

A blog is a layman-friendly variation of a website, and having a blog is one of the many ways to state your presence in the virtual world. While there are many hassle-free blog services out there that will take care of everything except automatically blog for you – like <a href="http://www.makeuseof.com/tags/blogger">Blogger and <a href="http://www.makeuseof.com/tags/wordpress">WordPress, nothing can beat a self-hosted blog in the terms of customization and self pride.

The problem is, the process of building your own self-hosted blog is (almost always) not free and is considered complicated. So most newbies will choose the easier path and never give themselves a chance to experiment.

Continue reading

Splitting strings with IFS

2010-02-04 2 min read Bash Linux

Today I want to discuss splitting strings into tokens or “words”. I previously discussed how to do this with the <a href="http://bashcurescancer.com/reading-a-file-line-by-line.html">IFS variable and promised a more in depth discussion. Today, I will make the case on WHY to use IFS to split strings as opposed to using a subshell combined with <a class="zem_slink freebase/en/awk" title="AWK" rel="homepage" href="http://cm.bell-labs.com/cm/cs/awkbook/index.html">awk or cut.

I wrote this script which reads the /etc/password file line-by-line and prints the <a class="zem_slink freebase/en/user" title="User (computing)" rel="wikipedia" href="http://en.wikipedia.org/wiki/User_%28computing%29">username of any user which has a UID greater than 10 and has the shell of /sbin/nologin. Each test function performs this task 10 times to increase the length of the test:

Continue reading

Kill processes that have been running for more than a week

2010-02-04 1 min read Linux

<a href="http://blog.amit-agarwal.co.in/category/linux/">Bookmark this category

<span style="font-size: x-large;"><a href="http://feedproxy.google.com/~r/Command-line-fu/~3/kr_otvdAVxA/kill-processes-that-have-been-running-for-more-than-a-week">Kill processes that have been running for more than a week
$ find /proc -user myuser -maxdepth 1 -type d -mtime +7 -exec basename {} ; | xargs kill -9

  • <a href="http://www.commandlinefu.com/commands/view/3702/kill-processes-that-have-been-running-for-more-than-a-week">View this command to comment, vote or add to favourites
  • <a href="http://feeds2.feedburner.com/commands/by/sharfah">View all commands by <a href="http://feeds2.feedburner.com/commands/by/sharfah">sharfah

<a href="http://www.commandlinefu.com"><img src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/header-logo.jpg" alt="commandlinefu.com" align="bottom" />

by David Winterbottom (<a href="http://codeinthehole.com">codeinthehole.com)

<a href="http://feedads.g.doubleclick.net/~a/NeXCFRlIt7EM3A_bb4x2jLaegwk/0/da"><img src="http://blog.amit-agarwal.com/wp-content/uploads/amit-agarwal.co.in/~a/NeXCFRlIt7EM3A_bb4x2jLaegwk/0/di" border="0" alt="" align="bottom" />
<a href="http://feedads.g.doubleclick.net/~a/NeXCFRlIt7EM3A_bb4x2jLaegwk/1/da"><img src="http://blog.amit-agarwal.com/wp-content/uploads/amit-agarwal.co.in/~a/NeXCFRlIt7EM3A_bb4x2jLaegwk/1/di" border="0" alt="" align="bottom" />

Continue reading

Color in grep output to distinquish the matching entries

2010-02-04 1 min read Linux

Most of the times I end up spending a lot of time to look for the string in the grep output when I do a search. This is quite frustrating and thus I looked at the options for grep command that would make my life easier and there definately is something. Here it is:

export GREP_COLOR=&#8221;5;36&#8221;

But for this to work you would still need to give the &#8221;–color=auto&#8221; option in the grep command. There are two ways to do this, create a alias for grep as &#8221;grep –color=auto&#8221; or specify the same in GREPOPTIONS.

Continue reading

Top 3 Sites To Help You Become A Linux Command Line Master]

2010-02-04 0 min read Linux
\"Programming
Image by fogus via Flickr

The truth about Linux today is that one may never have to actually <a class="zem_slink" title="Spice Girls" rel="homepage" href="http://www.thespicegirls.com">touch a terminal or issue a single Linux command in order to run some versions of this flexible alternative <a class="zem_slink" title="Operating system" rel="wikipedia" href="http://en.wikipedia.org/wiki/Operating_system">operating system. While there are times when using the Linux <a href="http://www.makeuseof.com/tag/an-introduction-to-the-linux-command-line/">command line could be expeditious and the benefits of possessing the ability to use it are numerous, many users can be intimidated by the prospect.

Continue reading

Damn Vulnerable Linux – DVL review

2010-02-04 1 min read Linux

Today morning I got a chance to look at one of the other less commonly known Linux Distribution and out of the line distribution, very good for Learning purposes. The distribution is known as DVL (Damn Vulnerable Linux). As the name suggest this is for people looking at developing their skills in Security and Penetration testing. Quite a lot of good and interesting tools are included. More is left for users to experiment but I definately liked the distribution. Here is the <a href="http://www.damnvulnerablelinux.org/" target="_blank">homepage.

Continue reading
Older posts Newer posts