LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-29-2007, 05:51 AM   #1
yusufs
Member
 
Registered: Oct 2007
Posts: 162

Rep: Reputation: 30
Text file Busy


Hai al,

am running a script which sends a mail.. but when i execute it is giving me the following error :



[root@oracle ~]# sh /root/test/tests/test/sysos.sh
/root/test/tests/test/sysos.sh: line 9: /usr/sbin/sendmail: Text file busy



Any idea

Yusuf
 
Old 12-29-2007, 07:15 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,361
Blog Entries: 55

Rep: Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547
Post the contents of your /root/test/tests/test/sysos.sh?
 
Old 12-29-2007, 07:19 AM   #3
yusufs
Member
 
Registered: Oct 2007
Posts: 162

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by unSpawn View Post
Post the contents of your /root/test/tests/test/sysos.sh?

Thanks unspawn, here it is :


[root@oracle ~]# cat /root/test/tests/test/sysos.sh
#!/bin/bash

set -xv

LOGFILE=/home/oracrp/test/sysos.log

echo "Logging system log at $(date)" >> "$LOGFILE"
# log vmstat. 3 * 5 second interval. Probably better than 1 second as it
# gives more time to average out the load analysis.

sar 1 5 >> $LOGFILE


#/usr/sbin/sendmail user@company.com << EOM
#FromBA
#To:Yusuf
#Subject:$(date +%d-%b-%Y) Alert Log Error

#EOM

# make a blank line between commands to help readability.
echo "" >> "$LOGFILE"

top -b -n 1 >> "$LOGFILE"
echo "" >> "$LOGFILE"

w >> "$LOGFILE"

#netstat -tap >> "$LOGFILE"
echo "" >> "$LOGFILE"
echo "" >> "$LOGFILE"


#/usr/sbin/sendmail user@company.com << EOM
#FromBA
#To:Yusuf
#Subject:$(date +%d-%b-%Y) SYSOS

#EOM

cat $LOGFILE | mail -s "Contents of my LOGFILE" user@company.com



Thanks
Yusuf

Last edited by yusufs; 12-29-2007 at 08:13 AM.
 
Old 12-29-2007, 07:27 AM   #4
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,259

Rep: Reputation: 318Reputation: 318Reputation: 318Reputation: 318
I would edit your post and remove your email unless you like spam.
 
Old 12-29-2007, 07:34 AM   #5
yusufs
Member
 
Registered: Oct 2007
Posts: 162

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by dive View Post
I would edit your post and remove your email unless you like spam.
dave, please remove it..

Yusuf
 
Old 12-29-2007, 07:49 AM   #6
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,259

Rep: Reputation: 318Reputation: 318Reputation: 318Reputation: 318
I can't edit it - only mods can edit other peoples posts

You just need to use the edit button under your post and delete it.
 
Old 01-03-2008, 07:35 AM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,361
Blog Entries: 55

Rep: Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547
Quote:
Originally Posted by yusufs View Post
/root/test/tests/test/sysos.sh: line 9: /usr/sbin/sendmail: Text file busy
Maybe wrong use of sendmail command? Here's my annotated version of your script:
Code:
#!/bin/sh --
# Set debug and or error mode when testing:
# set -xe
# Logfile name.
LOGFILE=/home/oracrp/test/sysos.log
# Subject of e-mail.
MAILSUBJ="Contents of ${LOGFILE//*\//}"
# Hostname in e-mail subject
MAILHOST=`hostname`
# E-mail recipient
MAILRCP="user@company.com"
# Function to echo a blank line, shorter than echoing all the time.
blank() { echo >> "$LOGFILE"; }
# Function to make message go to stderr.
error() { echo "$*" > /proc/self/fd/2; }
# No need to check logfile existence or clean up afterwards since we append to it.
echo "Logging system log at $(date)" >> "$LOGFILE"
# SAR likes a binary output file. Log to it, then read from it.
sar -o /tmp/sar.out 1 5 >/dev/null 2>&1 && sar -f /tmp/sar.out >> $LOGFILE; blank
top -b -n 1 >> "$LOGFILE"; blank; w >> "$LOGFILE"; blank
# Using '-n' with netstat makes it not resolve IP addresses which is faster.
# netstat -ntp >> "$LOGFILE"; blank
# Check if the logfile is in use which shouldn't happen.
/sbin/fuser "$LOGFILE" >/dev/null 2>&1; case "$?" in
 0) # Log who is bugging us.
    /sbin/fuser "$LOGFILE" | while read line; do
     error "Process using "${LOGFILE//*\//}": $line"; done; exit 1;;
 *) # Don't rely on /bin/mail ('mailx' package), use default MTA location.
    (echo "Subject: $MAILSUBJ on $MAILHOST"; \
    echo; cat "$LOGFILE") | /usr/sbin/sendmail -t $MAILRCP;;
esac
# Always exit
exit 0
It's untested so YMMV(VM) as usual. Notice that if you do
Code:
(echo "Subject: $MAILSUBJ on $MAILHOST"; echo; sar -f /tmp/sar.out; echo; top -b -n 1; echo etc etc) | /usr/sbin/sendmail -t $MAILRCP
you don't even need a logfile to write to unless you need to save, append or edit results before sending.
 
Old 01-05-2008, 07:12 AM   #8
yusufs
Member
 
Registered: Oct 2007
Posts: 162

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by unSpawn View Post
Maybe wrong use of sendmail command? Here's my annotated version of your script:
Code:
#!/bin/sh --
# Set debug and or error mode when testing:
# set -xe
# Logfile name.
LOGFILE=/home/oracrp/test/sysos.log
# Subject of e-mail.
MAILSUBJ="Contents of ${LOGFILE//*\//}"
# Hostname in e-mail subject
MAILHOST=`hostname`
# E-mail recipient
MAILRCP="user@company.com"
# Function to echo a blank line, shorter than echoing all the time.
blank() { echo >> "$LOGFILE"; }
# Function to make message go to stderr.
error() { echo "$*" > /proc/self/fd/2; }
# No need to check logfile existence or clean up afterwards since we append to it.
echo "Logging system log at $(date)" >> "$LOGFILE"
# SAR likes a binary output file. Log to it, then read from it.
sar -o /tmp/sar.out 1 5 >/dev/null 2>&1 && sar -f /tmp/sar.out >> $LOGFILE; blank
top -b -n 1 >> "$LOGFILE"; blank; w >> "$LOGFILE"; blank
# Using '-n' with netstat makes it not resolve IP addresses which is faster.
# netstat -ntp >> "$LOGFILE"; blank
# Check if the logfile is in use which shouldn't happen.
/sbin/fuser "$LOGFILE" >/dev/null 2>&1; case "$?" in
 0) # Log who is bugging us.
    /sbin/fuser "$LOGFILE" | while read line; do
     error "Process using "${LOGFILE//*\//}": $line"; done; exit 1;;
 *) # Don't rely on /bin/mail ('mailx' package), use default MTA location.
    (echo "Subject: $MAILSUBJ on $MAILHOST"; \
    echo; cat "$LOGFILE") | /usr/sbin/sendmail -t $MAILRCP;;
esac
# Always exit
exit 0
It's untested so YMMV(VM) as usual. Notice that if you do
Code:
(echo "Subject: $MAILSUBJ on $MAILHOST"; echo; sar -f /tmp/sar.out; echo; top -b -n 1; echo etc etc) | /usr/sbin/sendmail -t $MAILRCP
you don't even need a logfile to write to unless you need to save, append or edit results before sending.



Thanks a lot unspawn,, that really helped me..


Yusuf
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
scp text file busy error seran Linux - General 3 03-24-2010 10:21 AM
Steps needed to convert multiple text files into one master text file jamtech Programming 5 10-08-2007 12:24 AM
in Pascal: how to exec a program, discard text output or send to text file Valkyrie_of_valhalla Programming 6 05-02-2007 10:50 AM
How to find and change a specific text in a text file by using shell script Bassam Programming 1 07-18-2005 08:15 PM
/etc/rc.sysinit: /bin/awk: Text file busy teeno Linux - Software 5 02-23-2005 03:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration