473,394 Members | 1,811 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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

shrek123
How to read last to lines of a file present at remote server.
Dec 14 '07 #1
5 1445
numberwhun
3,509 Expert Mod 2GB
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
4,059 Expert 2GB
How you read it will depend on what type of access you have to the remote server.
Dec 14 '07 #3
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
3,509 Expert Mod 2GB
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
4,059 Expert 2GB
can't read files on a remote server like that anyway.
Dec 17 '07 #6

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

Similar topics

4
by: Rohith | last post by:
I need to import dlls that are present in the remote machine. Its a dll written in C that exposes methods. I want to import that dll in my C# application. But that dll is not present in the local...
7
by: Yongsub Eric Shin | last post by:
Hi. I'm just a beginner in ASP.Net. I started writing codes and I keep on getting this Runtime Error page, where it says "Description: An application error occurred on the server. The current...
0
by: Jerry | last post by:
Below is ALL the code for all the databases... Here's the problem: I callup the aspx file in IE and the form comes up just fine. When I select a person to update, I get the subject error. ...
2
by: Glen Conway | last post by:
Hi, I am trying to get the contents of a file in a hidden share on a remote server, something like '\\server.domain.com\c$\program files\application\document.xml'. When I try any of the...
3
by: JenHu | last post by:
Hi, I want read line by line and characters. The characters are fix length text file, no specific delimited method between each fields. The first line is header line, the last line is footer. ...
6
by: sree | last post by:
Hi, i want to check whether a file from remote server is existed or not. The file_exists() checks for local server only. But i want a function that checks the remote server.
6
by: Kinbote | last post by:
Hi, I'm trying to make a function that opens a file, reads it in line by line, puts each line into an malloc'd array, and returns the array. I suspect I'm going about it in an atypical fashion, as...
4
by: Ross | last post by:
Hello, I am trying to Read and Write to a text file on a web server using Microsoft Visual Basic 2005 Express Edition. So far I have managed to complete my testing with a local text file using...
4
by: Curious | last post by:
I have a file to which I'll need to at first read until it locates the last line of string. According to content of the last line of string, I'll need to write something to this file right after...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.