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

Hello Monks, I am trying to access a remote file situated on machine where the owner of the file is root.I wants to access the content of that file with some predefined function.The code is like this:

#!/usr/bin/perl BEGIN { unshift (@INC,"/view/sawans1_api_test/vobs/pp2dev/src/testsuite/user/t +inc"); unshift (@INC,"/view/sawans1_api_test/vobs/pp2dev/src/testsuite/user") +; } use DHPL::System; use nightly::common; use Logs::LogReader; $file = ` rsh -l root remote_machien cp /nightly_results/2010_03_19/re +mote_file.log ` ; # $file = "/path/remote_file/"; my $sul = SuiteLog->new( { FILE => $file } ); # $logfile is the log f +ile of test run $sul->parse_suite( ); # get_scheduled will return the list of all the test_suites present in + the respective test_run foreach my $sname ( @{$sul->get_scheduled( )} ) { my $scl = $sul->get_log( $sname ); my $name = $scl->name( ); my $result = $scl->result( ); my $errors = $scl->log_errors_short( ); my $description = $scl->get_decription( ); print"Test Suite Name = $name\n"; print"Result = $result\n"; print"Errors = $errors\n"; print"Description = $description\n"; }

If I used my rsh command like this then it is giving an error like this:

Can't open http://lcla238.lss.emc.com/nightly_results/2010_03_19/log_lcla133.lss.emc.com_64___TestSuiteDARE_Prod_MpaaPseudoIBM_AIX__3_19.html: No such file or directory at /view/sawans1_api_test/vobs/pp2dev/src/testsuite/user/tinc/Logs/LogReader.pm line 1344.

If I copied the same logfile to my home directory and then I assign the path of it $file like I have commented in above example then I gets proper out.But I wants to access any such file on the remote host at run time.How to achieve this using RSH??? Remember I have to pass path of that remote file like

$file = "/path/remote_file/"

this and have to access the same file through some pre-defined functions..

Kindly let me know about it...Thanks in advance !!!

Replies are listed 'Best First'.
Re: accessing remote file with rsh
by Corion (Patriarch) on Mar 22, 2010 at 18:25 UTC

    You seem to be confused.

    http://lcla238.lss.emc.com/nightly_results/2010_03_19/log_lcla133.lss. +emc.com_64___TestSuiteDARE_Prod_MpaaPseudoIBM_AIX__3_19.html

    is not something that cp understands, usually. Maybe you want to use LWP::Simple to fetch a file via http://? Or maybe you want to use rcp or scp to copy the file from the remote machine to your local machine? I've used the following to read a file on a remote machine as if it were a local file:

    open my $remote, "ssh $machine cat '$remote_filename'|" or die "Couldn't read $machine:$remote_filename: $!/$?";
      ya actually I dont have to use http:// ....it was typo....I went through your example but I could not able to found the file path and the user name.....The root is the owner of those files

        I don't understand what you mean. Maybe show the relevant part of the code you used, and maybe read the rsh documentation on how to pass a user etc.