reading file on a different machine

Discussion in 'Perl Misc' started by dcruncher4@aim.com, Jan 15, 2008.

  1. Guest

    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.
    , Jan 15, 2008
    #1
    1. Advertising

  2. Ben Morrow Guest

    Quoth :
    >
    > 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
    Ben Morrow, Jan 15, 2008
    #2
    1. Advertising

  3. Guest

    In article <>, Ben Morrow says...

    No nfs. In shell I would have to first do a rcp from the remote machine
    and then use the file locally.

    >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
    >
    , Jan 15, 2008
    #3
  4. Ben Morrow Guest

    [quoting fixed. please quote properly]

    Quoth :
    > In article <>, Ben Morrow says...
    > > Quoth :
    > > >

    <reading a file's mtime remotely>
    > >
    > >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
    Ben Morrow, Jan 15, 2008
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nico Grubert
    Replies:
    1
    Views:
    2,608
    Markus Rosenstihl
    Sep 21, 2005
  2. Steve Holden
    Replies:
    0
    Views:
    413
    Steve Holden
    Sep 21, 2005
  3. UJ
    Replies:
    2
    Views:
    417
  4. harijay
    Replies:
    2
    Views:
    480
    Gabriel Genellina
    Feb 19, 2009
  5. PerlFAQ Server
    Replies:
    0
    Views:
    124
    PerlFAQ Server
    Apr 9, 2011
Loading...

Share This Page