reading file on a different machine
am 15.01.2008 03:00:03 von unknownPost removed (X-No-Archive: yes)
Post removed (X-No-Archive: yes)
Quoth dcruncher4@aim.com:
>
> 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
Post removed (X-No-Archive: yes)
[quoting fixed. please quote properly]
Quoth dcruncher4@aim.com:
> In article
> > Quoth dcruncher4@aim.com:
> > >
> >
> >How would you do it without Perl? NFS? ssh? Windows Networking? If the
>
> 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