Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > reading file on a different machine

Reply
Thread Tools

reading file on a different machine

 
 
dcruncher4@aim.com
Guest
Posts: n/a
 
      01-15-2008
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.

 
Reply With Quote
 
 
 
 
Ben Morrow
Guest
Posts: n/a
 
      01-15-2008

Quoth http://www.velocityreviews.com/forums/(E-Mail 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

 
Reply With Quote
 
 
 
 
dcruncher4@aim.com
Guest
Posts: n/a
 
      01-15-2008
In article <(E-Mail Removed)>, 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
>


 
Reply With Quote
 
Ben Morrow
Guest
Posts: n/a
 
      01-15-2008
[quoting fixed. please quote properly]

Quoth (E-Mail Removed):
> In article <(E-Mail Removed)>, Ben Morrow says...
> > Quoth (E-Mail Removed):
> > >

<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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ 9.6 How do I download a file from the user's machine? How do I open a file on another machine? PerlFAQ Server Perl Misc 0 04-09-2011 04:00 PM
reading binary data from a 32 bit machine on 64 bit machine harijay Python 2 02-19-2009 08:31 PM
Directory structures different on development machine vs. install machine. UJ ASP .Net 2 10-24-2006 10:35 AM
How to copy a file from one machine to another machine Nico Grubert Python 1 09-21-2005 10:53 AM



Advertisments