- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- error mailing file in script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2003 04:39 AM
12-24-2003 04:39 AM
error mailing file in script
After the while loop I have an if statement that checks if -s then mails file.
Problem. If I run the script it does not send the email, the file exists but does not send the file.BUT, if I dont remove the file, and run it again, it emails it. Its like it does not see the file the first time.
Do I have to close the file, after the while / done
If so, how?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2003 04:41 AM
12-24-2003 04:41 AM
Re: error mailing file in script
How you are writing this is important.
Your first write to the file should be
output for example cat > filename
Subsequent output >> filename
The second statement appends.
Every time your script finishes appending, the file is closed.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2003 04:43 AM
12-24-2003 04:43 AM
Re: error mailing file in script
do
if [ "$UPTIME" -gt 1 ];then
#make a list of person, date and time resource removed
echo $NAME,$DATE,$TIME >> $PUNTED
exec $CLNUP "/pos:"$POS "/con:"$CON"\r"
fi
done < $FORTH_DOWN
ll $PUNTED
#if resources removed send email to admins
if [ -s $PUNTED ];then
echo "found someone to punt"
$MAIL -s "$SUBJECT" $MAILTO < $PUNTED
# $MAIL -s "$SUBJECT" $MAILTOCELL <
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2003 04:58 AM
12-24-2003 04:58 AM
Re: error mailing file in script
#Module used to send the email
use MIME::Lite;
#Initialize variables
my $from = 'reports@dcu_opc_gw2.dupagecu.com';
my $reply = 'hmahmoud@dcu_opc_gw2.dupagecu.com';
my $subject = 'Automated Report';
$testing = system("test -s $location");
if ($newfile =~ /rstagtb4.txt/) {
$newfile =~ s/.txt/.doc/;
}
if ($testing == 0) {
if ($newfile =~ /stmtprts.txt/) {
$mime_msg = MIME::Lite->new( #setup email message
From => $from,
To => $to_address,
CC => $reply,
"Reply-To"=> $reply,
Subject => "$newfile - $subject",
Data => $message1
)
or die "Error creating MIME body\n";
$mime_msg -> attach( #setup file attachment
Path => $location,
Filename=> $newfile
)
or die "Error attaching file\n";
$mime_msg -> send or die "Error sending report\n"; #send email
}
else {
$mime_msg = MIME::Lite->new( #setup email message
From => $from,
To => $to_address,
CC => $reply,
"Reply-To"=> $reply,
Subject => "$newfile - $subject",
Data => $message
)
or die "Error creating MIME body\n";
$mime_msg -> attach( #setup file attachment
Path => $location,
Filename=> $newfile
)
or die "Error attaching file\n";
$mime_msg -> send or die "Error sending report\n"; #send email
}
print "Report: $newfile, sent to $to_address\n";
-Hazem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2003 04:18 AM
12-26-2003 04:18 AM
Re: error mailing file in script
We use this extensively in our shop.
Regards,
dl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2003 09:58 PM
12-26-2003 09:58 PM
Re: error mailing file in script
this I found:
MAIL If this variable is set to the name of a mail file and
the MAILPATH variable is not set, then the shell
informs the user of arrival of mail in the specified
file.
what have you got in $MAIL?
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2003 10:00 PM
12-26-2003 10:00 PM
Re: error mailing file in script
can you post the output of the script?
have fun,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2003 03:34 PM
12-27-2003 03:34 PM
Re: error mailing file in script
I do not get any output. The script runs with no errors. There is data in the file to send.
If I put an ls right after the done of the while loop it does not find the file. Only after the script exits.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2003 10:18 PM
12-27-2003 10:18 PM
Re: error mailing file in script
please use another variable than $MAIL to avoid confusion with system variables. My suggestion: $MAILBIN
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2003 07:51 PM
12-28-2003 07:51 PM
Re: error mailing file in script
Use the following code:
while read a b c
do
if [ "${c}" -gt 1 ]
then
echo "${a}" >>output_file
${CLNUP} ${a} ${b} fi
done
if [ -s output_file ]
then
mailx -s Subject ${MAILTO}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2003 12:13 AM
12-29-2003 12:13 AM
Re: error mailing file in script
First...mailx is a messaging/broadcast utility. And according to some in the threads below..doesn't support sending attachments. Might I suggest try using something like elm (a mail processing system).
Here are a couple threads on sending attached files. There are a few ways to do this..some like 'uuencode' or 'mpack'. My personal favorite is the handy 'include' statement file, because of it's flexibility in sending any number of types of files...and getting them there the way you want.
Here is even an old quickie script I wrote once for doing this..hope you find it useful !
==================
#!/bin/sh
#
#
# This little script runs a couple
# Performance Programs for FileNet
# and then setups and emails them
# to user
# Written 11/30/00 by Rita Workman
###########################################
#
# Setup my only real variable
##############################
loc=/fnsw/local/tmp/perf
#
##############################
# Now cleanup/move any old files
# to ~/oldfiles for storage
# And run their Perf Programs
###############################
cat /dev/null /home/rworkman/dummy/jmailer
cat /dev/null /home/rworkman/dummy/tmp
mv $loc/*.Z $loc/oldfiles
cd /fnsw/local/ps
/fnsw/local/ps/perfreports.hpu
cd /fnsw/lib/perf
/fnsw/lib/perf/getreports
compress $loc/*
#
################################
# Setup Include file for email
################################
for mail in $loc/*
do
print "[include $mail application/msword base64]" >> /home/rworkman/dummy/tmp 0>&1
done
#
#
#
# Email it !!
################################
elm -s "Daily Performance Files from Rita $(date)" user@dot.com < /home/rworkman/dummy/jmailer
#
echo "Email to user done $(date)"
#
# all done !!
===========================
http://forums1.itrc.hp.com/service/forums/parseCurl.do?CURL=%2Fcm%2FQuestionAnswer%2F0%2C%2C0x41950559ff7cd4118fef0090279cd0f9%2C00.html&admit=716493758+1072703120567+28353475
http://forums1.itrc.hp.com/service/forums/parseCurl.do?CURL=%2Fcm%2FQuestionAnswer%2F1%2C%2C0xd6a2afe90f1cd71190050090279cd0f9%2C00.html&admit=716493758+1072703480470+28353475
Hope this helps,
Rgrds,
Rita