By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,529 Members | 1,826 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,529 IT Pros & Developers. It's quick & easy.

How to read last to lines of a file present at remote server.

shrek123
P: 23
How to read last to lines of a file present at remote server.
Dec 14 '07 #1
Share this Question
Share on Google+
5 Replies


numberwhun
Expert Mod 2.5K+
P: 3,503
How to read last to lines of a file present at remote server.
What have you tried so far? We want to see what you have been trying before giving you a nudge in the right direction. Who knows, you may have been on to something.

Regards,

Jeff
Dec 14 '07 #2

KevinADC
Expert 2.5K+
P: 4,059
How you read it will depend on what type of access you have to the remote server.
Dec 14 '07 #3

P: 33
Expand|Select|Wrap|Line Numbers
  1. my $fileName = "test.txt";
  2. open(FH_TEST, "<$fileName");
  3. my @filecontents = <FH_TEST>;
  4. ## navingate through the array for last to first as follows to get only last two lines.
  5. for (my $i = $#filecontents; $i <= $#filecontents -2; $i--)
  6. {
  7.     print "Line $i Content is : ", $filecontents[$i], "\n";
  8. }
  9. close(FH_TEST);
  10.  
Dec 17 '07 #4

numberwhun
Expert Mod 2.5K+
P: 3,503
Expand|Select|Wrap|Line Numbers
  1. my $fileName = "test.txt";
  2. open(FH_TEST, "<$fileName");
  3. my @filecontents = <FH_TEST>;
  4. ## navingate through the array for last to first as follows to get only last two lines.
  5. for (my $i = $#filecontents; $i <= $#filecontents -2; $i--)
  6. {
  7.     print "Line $i Content is : ", $filecontents[$i], "\n";
  8. }
  9. close(FH_TEST);
  10.  
mohanprasadgutta,

I don't know if you were aware of this, but this is a learning forum. We don't just provide code upon request. If this was, we would be a scripting/coding service.

If you read the post, we have asked the OP for their code that they have tried thus far so that we may assist them and thus, they can learn from it.

In the future, please do not just go throwing out code without first seeing what the OP has tried, to see if they were on the right track and maybe need a nudge.

Regards,

Jeff
Dec 17 '07 #5

KevinADC
Expert 2.5K+
P: 4,059
can't read files on a remote server like that anyway.
Dec 17 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.