thanks guru the problem was resolved .
but i got syntax error at error while executing . please help me friends,
Please put code inside [code] tags.
And please post real code that can be selected and copied to a file; if you want to put in line numbers, please do it in comments at the end of the line.
Quote:
Code:
1 #!/bin/ksh
2 ##
3 ##### To find no of files in the directory
4
5
6 NOF=`ls -l /root/COMM/LOGS/eds/20081025| wc -l`
There's no need to use external commands to get the number of files in a directory:
Code:
set -f
set -- /root/COMM/LOGS/eds/20081025/*
NOF=$#
Quote:
Code:
7 if [ $NOF -ne 0 ]
8 then
9 NOF=`expr $NOF - 1`
You are using ksh; why are you using an external command for arithmetic?
Code:
NOF=$(( $NOF - 1 ))
(But you don't need it if you don't use ls | wc.)
Quote:
Code:
10 fi
11
12 OUTFILE="/root/temp/checking/outputfile"
Are you really running buggy code as root????
That's asking for trouble.
Quote:
Code:
13 #OUTFILE= /root/temp/checking/outputfile
14 FILE=`cat /root/temp/checking/address.txt | wc -l`
15
16 echo " /root/COMM/LOGS/eds/20081025 no of files is ${NOF} " > $OUTFILE
17
18
19 if [ $NOF -ne 0 ]
20 then
21
22 for i in $FILE;
There is only one value in $FILE, so why are you using a loop?
Quote:
Code:
23 do
24 TO=`head -$i /root/temp/checking/address.txt | tail -1`
25
26 MFILE=/root/temp/checking/mailfile
27
28 echo "From: "Gnanaprakasam" <gnanaprakasam@yahoo.com>" > $MFILE
29 echo "To: ${TO}" >> $MFILE
30 echo "Date: `date`" >> $MFILE
31 echo "Subject: due to the script execution problem " >> $MFILE
32 echo "\n\n" >> $MFILE
33 echo "Dear Sir/Madam," >> $MFILE
34 echo "\n\t Due to the script execution problem the following file are created" >> $MFILE
35 echo "\n\n `ls -lt /root/COMM/LOGS/eds/20081025 |
tr -s " " | cut -f6,7,8,9 -d " " `" >> $MFILE
36 echo "\n" >> $MFILE
Group your commands (here and elsewhere) and use a single redirection:
Code:
{
echo "From: "Gnanaprakasam" <gnanaprakasam@yahoo.com>"
echo "To: ${TO}"
echo "Date: `date`"
echo "Subject: due to the script execution problem "
echo "\n\n"
echo "Dear Sir/Madam,"
echo "\n\t Due to the script execution problem the following file are created"
echo "\n\n `ls -lt /root/COMM/LOGS/eds/20081025 | tr -s " " | cut -f6,7,8,9 -d " " `"
echo "\n"
} > $MFILE
Quote:
Code:
37
38 ##/bin/cat $MFILE | /usr/sbin/sendmail -fgnanaprakasam@yahoo.com $TO
39 sleep 2
40 done
41
42 fi
43
44
45
46
47
48 NOF1=`ls -l /root/COMM/LOGS/eds/20081215 | wc -l`
49 if [ $NOF1 -ne 0 ]
50 then
51 NOF1=`expr $NOF1 - 1`
52 fi
53
54 echo text >> $OUTFILE
55 DIRFILE=/root/COMM/LOGS/eds/20081215
56 echo "/root/COMM/LOGS/eds/20081215 no of files is ${NOF1} " >> $OUTFILE
57 if [ $NOF1 -ne 0 ]
58 then
59 for j in $DIRFILE;
How to automate FTP files daily with the following constraints
1) Try (every 15 mins or 30 mins) FTP till it reconnects
2) Files that arrive in between 5:30 pm and 2:00 am
3) The sat and sun, mon files are to be FTP on monday.
4) Only the txt files are to be FTP'ed.
The following are the... (2 Replies)
I am a new member of this forum and am also new to unix shell scripting.
I joined the forum to seek for help to achieve my task as this forum helps people.
here's what i do manually on daily basis
1)Loginto different unix box
2)Ftp the log files (morethan 50 each dir) to windows
3)use text pad... (3 Replies)
Hi there,
I have to automate daily monitoring process and then the result of these process should be sent to a log file, then this log file should be mailed .
ps -ef | grep aa
In this atleast one process should run.
If the process is running it should mention Success in the log file... (3 Replies)
Hi all,
This is my sample code in /etc/httpd/conf.d/applications.conf file currently we are creating subdomain mannually for every new subdomain. I want to automate this process througs bash script , how its possible.
<VirtualHost *:80>
ServerName google.com
ServerAlias google.com... (5 Replies)
Hi,
I am trying to create a shell script to automate the following process of getting svn stats:-
Step1:- cd to checkout location.
Note that the checked code have multiple modules in respective folders
Step2:- Execute this command inside each module:-
svn log -v --xml >... (0 Replies)
Hi, guys, I am trying to automate a sftp process using "expect" method (since the key authentication method is disabled in my company network, there is no helping it).
In order to try, I type in the command manually:
sftp @ > << EOF
>cd
>ls -l
>EOF
>Connecting to
@servername password:
... (3 Replies)
find /usr/IBM/FileNet/BulkUploaderScript/$i/Log/SuccessLog \( -newer range_start -a \! -newer range_end \)
-exec wc -l {} \; |awk '{total+=$1-1} END {print total}' >>$LOGFILE
I need to print time stamp of the files int the paticular period .Please modify the above script so that i get... (34 Replies)
Hi friends,
I am quite used to using glance in HPUX servers for analysis performance issues with a particular process as requested by app. folks.
The options which are very helpful to me are the "F" , "W" , "L" stats. How can i get the similar details on Linux servers without using glance?... (2 Replies)
Hello All!
First post...
I am working on a script that is used to recover a crashed drive from an rsync backup.
I'm down to the place where I need to create all of the directories in /mnt where I will then mount each of the volumes and begin the restore process to each volume...
I have... (3 Replies)
Hello!
Need help to write a Linux script that can be run from windows using command/Cygwin/any other way. I am new to scripting, actually i am trying to automate server health check like free disk space, memory along with few services status, if any services is not running then start services ,... (7 Replies)