LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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-15-2011, 04:13 AM   #16
Vi_rod
Member
 
Registered: Dec 2011
Posts: 42

Original Poster
Rep: Reputation: Disabled

Quote:
Originally Posted by asimba View Post
Well noticed!

----

Correct would have been this one
Code:
[[ ! -z  `mount | grep -i ip` ]] &&  echo "ip is mounted" || mail -s "ip not mounted" someone@somwhere.com
^ good one-liner code! thanks
 
1 members found this post helpful.
Old 12-15-2011, 04:16 AM   #17
asimba
Member
 
Registered: Mar 2005
Location: 127.0.0.0
Distribution: Red Hat / Fedora
Posts: 355

Rep: Reputation: 42
I am glad I could help.
 
Old 12-15-2011, 04:18 AM   #18
Vi_rod
Member
 
Registered: Dec 2011
Posts: 42

Original Poster
Rep: Reputation: Disabled
I have named the text file as "test.log" and i thought it would keep adding - one line "Disk is mounted" instead of replacing. Pls help in getting threaded log file..
ex:line 1. disk is mounted $date
line 2. disk is mounted $date
instead of one single line - disk is mounted $date.
 
Old 12-15-2011, 04:20 AM   #19
Vi_rod
Member
 
Registered: Dec 2011
Posts: 42

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Cedrik View Post
/dev/null is your OS black hole, it isn't overwritten, it absorbs everything you send to it

2>&1 is a bash expression, it means send error output (#2) to standard output (#1)

So sending output > /dev/null 2>&1 means suppress both standard and error output
^ @ O.S black hole -> lol , neat explanation though! thanx!
 
Old 12-15-2011, 04:21 AM   #20
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
Use ' >> ' instead of ' > ' to append line to test.log file
 
1 members found this post helpful.
Old 12-15-2011, 04:41 AM   #21
Vi_rod
Member
 
Registered: Dec 2011
Posts: 42

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Cedrik View Post
Use ' >> ' instead of ' > ' to append line to test.log file
great! works
 
1 members found this post helpful.
Old 12-15-2011, 05:04 AM   #22
asimba
Member
 
Registered: Mar 2005
Location: 127.0.0.0
Distribution: Red Hat / Fedora
Posts: 355

Rep: Reputation: 42
came in late
 
Old 12-15-2011, 05:18 AM   #23
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,420

Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
Hey rod,

You can also check out this script, if it helps you:

varcheck=`mount | grep “/sda1″`
if [[ ${#varcheck} == 0 ]]
then
#Attempt to mount
`mount /dev/sda1 2>/dev/null`
varcheck=`mount | grep “/sda1″`
if [[ ${#varcheck} == 0 ]]
then
echo “Could Not Mount /dev/sda1″ | mail -s ‘External Backup – Could Not Mount Drive’ $MAILLIST
exit
fi
fi
 
  


Reply



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
Sending mail from shell script sinoob Linux - Server 3 07-07-2011 07:43 AM
problem with sending mail from script vedaprasad Programming 6 03-18-2011 09:31 PM
Sending mail with subject in Linux script 151803 Linux - General 5 01-25-2007 04:46 AM
Shell script sending mail mfrick Linux - General 5 09-01-2005 07:46 PM
How to Do the Following? Running Script at Boot-Time + Sending Mail LinuxGeek Linux - General 1 07-20-2004 12:06 AM

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

All times are GMT -5. The time now is 09:42 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
Open Source Consulting | Domain Registration