jump to navigation

Bash Shell script to check the existence of a file under your linux filesystem August 3, 2010

Posted by networknuts in Uncategorized.
Tags: , , , , , , , , , , , , , , ,
1 comment so far

Here is a very small but useful shell script that will check the existence of a file and report accordingly.

#!/bin/bash
#by alok srivastava
#check the existence of a file under your filesystem
#this bash shell script use "positional parameters"

file=$1
[ $# -eq 0 ] && { echo "Usage: $0 filename"; exit 999; }
if [ -f $file ];
then
echo "YES - File $file exists."
else
echo "NO - File $file does NOT exists."
fi

It can be very useful while creating more complex bash shell scripts.

Here is a sample execution shown for your reference:

Shell Script taking Time bound Input !! May 13, 2010

Posted by networknuts in Uncategorized.
Tags: , , , , , , , , ,
add a comment

Here is a simple shell script that will take the input from user keyboard and displays it on the screen. But the idea is not that!!!

Idea is to show you, how to take “time bound” input for sensitive information.

vim timed_read.sh

and here is the script…

#!/bin/bash
#alok srivastava
#taking time bound input

TIMEOUTLIMIT=4  # 4 seconds of wait

echo “type something “
read -t $TIMEOUTLIMIT first <&1
echo

if [ -z "$first" ]
then
echo “timed out.. sorry”
else
echo “you typed $first”
fi

exit 0   # exit clean

When you execute this script using “sh time_bound.sh” and give some input within the time frame of 4 seconds it will be displayed.. else the script will exit cleanly after waiting for 4 seconds. As shown:

time bound script output

Output of above Script

God Bless.

Linux Bash Shell Script to clear logs automatically – VIDEO April 25, 2010

Posted by networknuts in Uncategorized.
Tags: , , , , , , , , , , , , ,
add a comment

Video by www.networknuts.net, showing how to create a linux bash shell script to clear logs automatically and carefully.

God Bless.

Apache Load Balancing VIDEO using “pound” April 5, 2010

Posted by networknuts in 1.
Tags: , , , , , , , , , , , , , ,
add a comment

Check the apache load balancing done using “pound” video on – You Tube.

http://www.youtube.com/watch?v=-WuW27hpHWc

God Bless.

100% Result in RHCSS (EX 429) exam April 3, 2010

Posted by networknuts in 1.
Tags: , , , , , , , ,
add a comment

Network NUTS congratulates all his students for creating one more landmark in Red Hat Linux RHCSS certification.

In the last “Red Hat Enterprise SELinux Policy Administration (EX429)” exam held on 02/04/2010, Network NUTS has achieved 100% pass result.

Congratulates to all the Certified Students:

Mr. Rajnesh Kr. Siwal
Mr. Aditya Gandhi
Mr. Tarpan
Mr. Prabhat Chauhan
Mr. B. Sudhir
Mr. K.R Venkataraman

Network NUTS wishes you all the best!!!

Block music/download through Squid February 26, 2010

Posted by networknuts in 1.
Tags: , , , , , , , , , , , ,
add a comment

We might need to BLOCK certain types of files to be downloaded, like mp3/mpeg/avi/exe and other and display our customized error-message.

STEP #1 – vim /etc/squid/squid.conf — add these lines under your ACL section

acl   blockfiles   urlpath_regex   "/etc/squid/blocks.files.acl"
# Deny all blocked extension
deny_info ERR_BLOCKED_FILES blockfiles
http_access deny blockfiles

STEP #2 – Create rule file for blocking certain types of file.

vi /etc/squid/blocks.files.acl

\.[Ee][Xx][Ee]$
\.[Aa][Vv][Ii]$
\.[Mm][Pp][Gg]$
\.[Mm][Pp][Ee][Gg]$
\.[Mm][Pp]3$

STEP #3 – Create customized error file under /usr/share/squid/errors/English/ directory.

vi ERR_BLOCKED_FILES

<HTML>
<HEAD>
<TITLE>ERROR: Blocked file content</TITLE>
</HEAD> <BODY>
<H1>File is blocked due to our IT policy</H1>
<p>Please contact Network NUTS admin for more information:</p>

STEP #4 - Restart the squid service.

service squid restart; chkconfig squid on

God Bless.

Check more on linux at http://networknuts.net

Disable mail alert by CRON January 25, 2010

Posted by networknuts in 1.
Tags: , , , , , , , ,
add a comment

Normally, we had seen that after the crontab executes your cron job it sends you a email as a notification on root email.

I don’t want the email to be send on root account.

Here is how you can do this:

METHOD #1 - Add any one of the following at the end of the line for each cron job to redirect output to /dev/null.

>/dev/null 2>&1.
OR
&> /dev/null

Example – 1:

40 16 * * * /bin/echo "this will not be emailed to root"  > /dev/null 2>&1

Example – 2:

40 16 * * * /bin/echo "this will not be emailed to root"  &> /dev/null

So when this command will be executed by cron, NO email will be send on root account.

METHOD #2 – Disable mail by using MAILTO variable.

Just when you do crontab -e for editing your cron jobs. Add

MAILTO=" "

as your first line in the crontab file.

Enjoy.

God Bless.

Sapient India trust Network NUTS for MS Exchange training October 28, 2009

Posted by networknuts in 1.
Tags: , , , , , ,
add a comment

Sapient India ( http://www.sapient.com/en-in)

One of the world’s top business and IT consulting company has chosen “Network NUTS” for their Microsoft Exchange 2007 training to be imparted to their technical staff.

The training is scheduled to start in November, 2009.

Our high technical standards are also acknowledged by world’s top IT companies.

“Our students set our standards, our job is to meet them”

Follow

Get every new post delivered to your Inbox.

Join 484 other followers