siddheshsawant has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks !!!

I have question on processing file situated on remote host.I have 3 machines like A,B & c.A file test_log is situated on machine C.On machine B there is perl module to I have to pass test_log file through perl script written on machine A.I have done following processing:

#!/usr/bin/perl -w BEGIN { unshift (@INC,"/PATH/TO/PERL/MODULE/ON/MACHINE/B"); } require LogReader.pm; <---module on machine B my $log_file= "/a/path/to/remote/log/file/on/machine/c"; open(fp, $log_file) or die ("could not open the file"); # line no 10 my $sul = SuiteLog->new( { FILE => fp } ); <---Suitelog is a another +module defiend in perl module on machine B which does processing on t +he content of test_log .

I am getting error like as follows:

could not open the file at ./script_on_machineA.pl line 10.

If anybody knows how to process a file on the remote host then please help me out !!!! Thanks in advance !!!!

Replies are listed 'Best First'.
Re: accessing files on rmote host
by ahmad (Hermit) on Mar 19, 2010 at 21:11 UTC

    To access a file on remote machine you'll have to use some kind of a protocol like HTTP, FTP, SSH ...etc

      True, but you seem to imply that

      /a/path/to/remote/log/file/on/machine/c

      could not map to a remote file as the OP claimed, and that's not true. All of the protocols you mentioned can be integrated into the file system. In fact, you didn't list SMB and NFS which are often if not always integrated into the file system.

      It could be that the OP just made up a path and hoped it would somehow allow him to access a remote file, in which case HTTP, SFTP, etc would prove to be potential solutions.

      But here on, I'm going to assume the path the OP is using should access a remote file. A good way to verify this is to check if it works outside of Perl, say by passing it to ls/dir. If not, then there's no reason to expect it to work in Perl. However, if it does work in the shell, you should have every expectation that it will also work in Perl.

      Some things to check:

      • Can you list that file with ls/dir?
      • Are you sure the string you are passing to open is the same you are passing to ls/dir?
      • Is the Perl script run by a different user (with different permissions) than the one as which you ran ls/dir?

      It might help to know why open failed by including $! in the error message.

        As I remember opening a file through smb requires you adding "smb:/" In front of the file name.

        I did not take the time to list all the available options I know there are more so I just finish with "...etc"

        I think the OP should have told us how he's accessing the remote file system without using scripts