reading file on a different machine

D

dcruncher4

Hi,

I am writing a script which has to execute very fast since it is part of
an alert script. One of the things it needs to do is to read a config
file sitting on a remote machine.

I need to accomplish two things:

a - Read the file creation time/update time of the config file
on the remote machine.

b. read the contents of it.

How can it be done in Perl. Which modules to use.

TIA.
 
B

Ben Morrow

Quoth (e-mail address removed):
I am writing a script which has to execute very fast since it is part of
an alert script. One of the things it needs to do is to read a config
file sitting on a remote machine.

I need to accomplish two things:

a - Read the file creation time/update time of the config file
on the remote machine.

b. read the contents of it.

How can it be done in Perl. Which modules to use.

How would you do it without Perl? NFS? ssh? Windows Networking? If the
file can be accessed normally on your machine (if it's on a networked
filesystem you can access) you can use File::stat (or the stat builtin)
and File::Slurp to do what you ask, although note that unless you are on
Win32 files don't generally have a 'creation time' you can easily read
from Perl. Under Win32 the ctime member of the stat structure contains
the creation time (this is *not* the case under other OSs). If you need
to get at the file more indirectly, you will have to tell us how.

Ben
 
B

Ben Morrow

[quoting fixed. please quote properly]

Quoth (e-mail address removed):
No nfs. In shell I would have to first do a rcp from the remote machine
and then use the file locally.

Do that in Perl then. You can invoke rcp (presumably with -p) using
system. Then you can use File::stat and File::Slurp, as I said before.

Perl doesn't have any magic way of getting at files you can't get at
normally.

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top