?
Solved

need help with the watchmail command

Posted on 2009-04-05
9
Medium Priority
?
283 Views
Last Modified: 2012-05-06
Hey, I need to implement a watchmail command in a shell, what its supposed to do is take a file name as an argument and beep if its size changes... I was thinking it could be done with a read file command and storing the number of bytes and check if it changes like that, is it that simple or a bit more complicated?
0
Comment
Question by:errang
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 53

Expert Comment

by:Infinity08
ID: 24070537
You can't simply depend on the file size changing ... What if a byte was simply overwritten (ie. not added or removed) ?

The most direct way to do that would be to hook into the system file operation calls, but that's rather complicated, and probably not what you'd like.

A good alternative however, is to watch the file modification timestamp, and see whether that changes.
0
 

Author Comment

by:errang
ID: 24070602
oh sweet... there's no built in command for that.. is there?
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 24070820
What do you mean by a built-in command ? For doing what ?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:errang
ID: 24070834
a built in command to get the time stamp, or do I just need to have the shell list everything about the file and parse the time stamp from that?
0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 2000 total points
ID: 24070870
You can use the stat function for that :

        http://linux.die.net/man/2/stat
0
 

Author Closing Comment

by:errang
ID: 31566713
Thanks, that function was not the first choice on my list... lol.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 24072281
>> that function was not the first choice on my list... lol.

Why not ? Were you looking for something else ?
0
 

Author Comment

by:errang
ID: 24072290
no no... I thought I would have to use a file listing command, and somehow parse it... this was way better =D
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 24072308
Heh. That's for sure - especially since the parsing would have to deal with possibly different output formats on different systems.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
Suggested Courses
Course of the Month9 days, 18 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question