Link to home
Start Free TrialLog in
Avatar of errang
errangFlag for Afghanistan

asked on

need help with the watchmail command

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?
Avatar of Infinity08
Infinity08
Flag of Belgium image

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.
Avatar of errang

ASKER

oh sweet... there's no built in command for that.. is there?
What do you mean by a built-in command ? For doing what ?
Avatar of errang

ASKER

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?
ASKER CERTIFIED SOLUTION
Avatar of Infinity08
Infinity08
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of errang

ASKER

Thanks, that function was not the first choice on my list... lol.
>> that function was not the first choice on my list... lol.

Why not ? Were you looking for something else ?
Avatar of errang

ASKER

no no... I thought I would have to use a file listing command, and somehow parse it... this was way better =D
Heh. That's for sure - especially since the parsing would have to deal with possibly different output formats on different systems.