HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- how to suppress an error in a mail command
Operating System - Linux
1828224
Members
2047
Online
109975
Solutions
Forums
Categories
Company
Local Language
back
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
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
03-23-2011 01:17 AM
03-23-2011 01:17 AM
how to suppress an error in a mail command
I have written something like this to send me filesystem status every 2 hours. i run this as a cron.
[script]
df -h > /home/ap/fsstatus.txt
uptime >> /home/ap/fsstatus.txt
mail -s "haad-oas1 File System Status" ap@gmail.com < /home/ap/fsstatus.txt
[/script]
when this mail goes through exchange it throws an exception bounce back email with the following text
[bounceback mail contents]
tar: Removing leading `/' from member names
/var/log/messages
[/bounceback mail contents]
how can i avoid this.
thanks
[script]
df -h > /home/ap/fsstatus.txt
uptime >> /home/ap/fsstatus.txt
mail -s "haad-oas1 File System Status" ap@gmail.com < /home/ap/fsstatus.txt
[/script]
when this mail goes through exchange it throws an exception bounce back email with the following text
[bounceback mail contents]
tar: Removing leading `/' from member names
/var/log/messages
[/bounceback mail contents]
how can i avoid this.
thanks
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2011 02:13 AM
03-23-2011 02:13 AM
Re: how to suppress an error in a mail command
You've redirected the standard output (stdout) of your commands to file fsstatus.txt, but the standard error output (stderr) is not redirected.
The messages you're seeing are sent to stderr by the tar command.
The syntax to redirect stderr to a file is "2> somefile" or "2>> somefile", similar to ">" and ">>" used for redirecting stdout. There is also a shorthand "2>&1" which means "send the stderr output to the same place where the stdout is going." The numbers refer to standard file descriptor numbers: stdin is #0, stdout is #1 and stderr is #2.
So you might modify your script like this:
--------
df -h > /home/ap/fsstatus.txt 2>&1
uptime >> /home/ap/fsstatus.txt 2>&1
mail -s "haad-oas1 File System Status" ap@gmail.com < /home/ap/fsstatus.txt
--------
MK
The messages you're seeing are sent to stderr by the tar command.
The syntax to redirect stderr to a file is "2> somefile" or "2>> somefile", similar to ">" and ">>" used for redirecting stdout. There is also a shorthand "2>&1" which means "send the stderr output to the same place where the stdout is going." The numbers refer to standard file descriptor numbers: stdin is #0, stdout is #1 and stderr is #2.
So you might modify your script like this:
--------
df -h > /home/ap/fsstatus.txt 2>&1
uptime >> /home/ap/fsstatus.txt 2>&1
mail -s "haad-oas1 File System Status" ap@gmail.com < /home/ap/fsstatus.txt
--------
MK
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2011 02:18 AM
03-23-2011 02:18 AM
Re: how to suppress an error in a mail command
oh... ok
i forget the basics too often for comfort.
and further the tar error is being thrown by another script.
thank you Matti
i forget the basics too often for comfort.
and further the tar error is being thrown by another script.
thank you Matti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2011 04:24 AM
03-23-2011 04:24 AM
Re: how to suppress an error in a mail command
> and further the tar error is being thrown
> by another script.
Probably one with a "tar" command in it.
("tar:" was a clue.)
And you could avoid this complaint by
specifying a relative path ("fred") instead
of an absolute path ("/fred") there, which is
generally considered a better practice for
various reasons (which is why "tar" is trying
to "help" you this way).
man tar
> by another script.
Probably one with a "tar" command in it.
("tar:
And you could avoid this complaint by
specifying a relative path ("fred") instead
of an absolute path ("/fred") there, which is
generally considered a better practice for
various reasons (which is why "tar" is trying
to "help" you this way).
man tar
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP