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
Solved

need help with the watchmail command

Posted on 2009-04-05
9
278 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
  • 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

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 500 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

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

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

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files 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.

856 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