Programming in almost language

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

  • Categories

  • LinkedIn

  • Tweet Me

    Error: Twitter did not respond. Please wait a few minutes and refresh this page.

  • My footsteps

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 yourdomain.com 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.

kdarious@gmail.com

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 ==============================================================

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

filename2=/usr/local/apache/domlogs/user/domain.com #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}’`

day=$month/$year
grep $day $filename2 > $filename6
echo “”>$filename3
echo “”>$filename1
echo “”>$filename4

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

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

Posted in Learning Linux | Leave a Comment »