Programming in almost language

This is the site where you may share your knowledge and experience to eachother..

  • Categories

  • LinkedIn

  • Tweet Me

  • My footsteps

  • Advertisements

Archive for the ‘Learning Linux’ Category

Here You all will get the basics of Linux

Fedora/Linux/CentOS user can have a better understanding with these topics.

Creating an alias as a non root user .

Posted by Pratap on August 3, 2009

Hi folks!!!

Many of you have faced the same problem for creating an alias of the frequently used command .

But here is another way to do it . It is not just to add alias using alias command which will enable the particular alias for particular session and console . I am not going to use alias command to create aliases .

I would suggest you (if you do not have root access ) to write a script which will help you to use it like an alias .

For example suppose you want to create the alias for telnet command , for root user it is easy to create , by adding a single line to .bashrc file but for a non-root user this is very handy .

vi t ### create a filename with t name

####add the following line to this file

telnet $1 $2

###save and quit :wq

chmod 777 t

now use the following command

./t 25

#### voila it is working

Now it depends on you to choose it or reject it .
In the same way you can create many script for your aliases.


Posted in Learning Linux | Tagged: | Leave a Comment »

Shell Script for collecting information from domlogs.

Posted by Pratap on May 18, 2009

Write a scripts which can generate a output for all media/source files which has been downloaded in the month.

This is an easy way I found you may try ==============================================================

filename1=/root/mail_body_file.txt # main file to copy media files name

filename2=/usr/local/apache/domlogs/user/ #domlogs

filename3=/root/out_put.txt # raw out put

filename4=/root/output.txt # final out put

filename5=/root/mail_body_file2.txt # replaced ” ” with “%20”

filename6=/root/mail_body_file3.txt # temp dom log file for search

current_date=”echo `date`”

month=`date | awk ‘{print $2}’`

year=`date | awk ‘{print $6}’`

grep $day $filename2 > $filename6
echo “”>$filename3
echo “”>$filename1
echo “”>$filename4

#touch /root/
find /home/user/public_html/* -type f | grep -E \.mp3$ > $filename1
find /home/user/public_html/* -type f | grep -E \.midi$ >
find /home/user/public_html/* -type f | grep -E \.mid$ >>
find /home/user/public_html/* -type f | grep -E \.swf$ >>

sed ‘s/ /%20/g’ $filename1 > $filename5
sed “s%\/home\/user\/public_html%\ %g” $filename5
> /root/
for i in `cat /root/`; #media file anme
for j in `cat $filename6`; # domlogs
if [ `echo $i` = `echo $j` ]; # matching string
count=`expr $count + 1`
echo “$i”, $count >>$filename3 #storing the match in a file as raw output
sed ‘s/%20/ /g’ $filename3 > $filename4 # output to send in mail

Posted in Learning Linux | Leave a Comment »