Solved

need help with the watchmail command

Posted on 2009-04-05
9
277 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
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 and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

778 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