LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 04-02-2005, 07:04 AM   #1
EgosZ
LQ Newbie
 
Registered: Jun 2004
Location: Australia
Distribution: Fedora Core 3, Suse Professional 9.2
Posts: 17

Rep: Reputation: 0
Display a text file from hard drive into a web page


Hi everyone

I am currently getting to learn HTML and would like to construct a site on my Apache server 2.0. Recently I have run through a problem of getting the web page showing whatever content of a specific file on user's hard drive (e.g /etc/passwd). In Windows, everything would be easy for example if i wanna see the content of a file name txt.txt on drive C I just feed in the tag <a href="c:\txt.txt"> but with Linux it doesn't work that way. I have tried many ways but only got it works when i type in the browser the full path of my index file on the server (saying /var/www/html/index.html) and the tag would be <a href="/etc/passwd"> or using relative path <a href="../../../etc/passwd">. However when i use localhost to call my homepage, the link seems not to work anymore.

What should I do to get the link works when I type in localhost in the address bar?

Any thoughts would be appreciated. Thanx
 
Old 04-02-2005, 09:51 AM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
When you "use localhost" I assume you are accessing it through a webserver. The webserver will only have limited access to the filesystem as defined in its configuration.

If you access the files directly from your hard drive then you can access any file that your user has access to. If you are trying to link between the 2 then use "file:///path/to/file" for local files.
 
Old 04-02-2005, 05:57 PM   #3
EgosZ
LQ Newbie
 
Registered: Jun 2004
Location: Australia
Distribution: Fedora Core 3, Suse Professional 9.2
Posts: 17

Original Poster
Rep: Reputation: 0
Hi David

Thanks for your reply. I did try file:///etc/passwd but no result. The link doesn't work eventhough it appears to be a hyperlink there. The page staystillls when I click on the link....

Any thoughts?

Cheers
 
Old 04-03-2005, 11:45 AM   #4
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
What browser are you using?

What are the permissions on the file:
ls -l /etc/passwd
 
Old 04-04-2005, 03:24 AM   #5
EgosZ
LQ Newbie
 
Registered: Jun 2004
Location: Australia
Distribution: Fedora Core 3, Suse Professional 9.2
Posts: 17

Original Poster
Rep: Reputation: 0
Hi

I am using Firefox and permission of the /etc/passwd file is -rw-r--r--

Hope that it helps
 
Old 04-04-2005, 09:03 AM   #6
EgosZ
LQ Newbie
 
Registered: Jun 2004
Location: Australia
Distribution: Fedora Core 3, Suse Professional 9.2
Posts: 17

Original Poster
Rep: Reputation: 0
I have finally figured out a way to display a content of a txt file from local hard drive to webpage. I use a php fopen() script. I worked out perfect as I now can see the content of /etc/passwd with ease.

Just posting the solution here so anyone can have a look

Cheers
 
Old 04-04-2005, 10:51 PM   #7
Tenox
LQ Newbie
 
Registered: Apr 2005
Location: Atlanta
Distribution: RH9
Posts: 9

Rep: Reputation: 0
Quote:
Originally posted by EgosZ
I have finally figured out a way to display a content of a txt file from local hard drive to webpage. I use a php fopen() script. I worked out perfect as I now can see the content of /etc/passwd with ease.

Just posting the solution here so anyone can have a look

Cheers
--

One way to to access files on your system is to create links to them within the hierarchy that your web server is set up to access. In *nix, links are made using the ln command. Symbolic or soft links are most likely what you'd be interested in. You can link to either files or directories. You can also move the links about without any penalty. It's pretty handy if you use partitions or separate drives to organize a lot information; you can then include the entire partition under a top level link.

Basically, it's another way of getting around the limitations imposed by the configuration of your web server, which can access files only contained within its defined server_root. You can also change the configuration, but that's more advanced. You should be aware of links.

/..
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I display real shell script output to web page. farmerjoe Programming 1 04-07-2005 01:03 PM
set focus on a text form of a web page? codec Programming 2 12-31-2004 04:32 AM
Second hard drive won't display:( gamecat Mandriva 4 09-06-2004 03:53 AM
Display/Read line 'N' in a text file using script ganninu Linux - Newbie 2 10-13-2003 05:28 AM
how hard would making 'socket based web page retriever' be? doublefailure Linux - Networking 2 04-24-2003 08:36 PM


All times are GMT -5. The time now is 02:39 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration