473,396 Members | 2,021 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,396 software developers and data experts.

PHP and Reading Linux Text Files

let's say i have a linux text file located and named...

/var//status/info

it has a "0" or a "1" in it to indicate on or off.

can php read this file even though it isn't in the apache html
directory tree? if so, how is this done?

tia...

Feb 17 '06 #1
3 1282
d
"Skeets" <sk*********@yahoo.com> wrote in message
news:11********************@g44g2000cwa.googlegrou ps.com...
let's say i have a linux text file located and named...

/var//status/info

it has a "0" or a "1" in it to indicate on or off.

can php read this file even though it isn't in the apache html
directory tree? if so, how is this done?
$status=file_get_contents("/var/status/info");

:)

PHP is just a program, and as such can read anything in the computer it has
access to. As long as the user under which Apache runs can read that file,
then PHP can when it's being run from your webserver.
tia...


hope that helps!

dave
Feb 17 '06 #2
On Fri, 17 Feb 2006 17:12:39 +0000, d wrote:
"Skeets" <sk*********@yahoo.com> wrote in message
news:11********************@g44g2000cwa.googlegrou ps.com...
let's say i have a linux text file located and named...

/var//status/info

it has a "0" or a "1" in it to indicate on or off.

can php read this file even though it isn't in the apache html
directory tree? if so, how is this done?


$status=file_get_contents("/var/status/info");

:)

PHP is just a program, and as such can read anything in the computer it has
access to. As long as the user under which Apache runs can read that file,
then PHP can when it's being run from your webserver.
tia...


hope that helps!

dave


Safe mode may get in your way???

Feb 17 '06 #3
On 2006-02-17, Skeets <sk*********@yahoo.com> wrote:
let's say i have a linux text file located and named...

/var//status/info

it has a "0" or a "1" in it to indicate on or off.

can php read this file even though it isn't in the apache html
directory tree? if so, how is this done?


this is the easiest way:

$value=file_get_contents("/var/status/info");

--

Bye.
Jasen
Feb 18 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: ..:: sjf ::.. | last post by:
Hello Pythoners! There are a lot of files containing data such as: file1: 0950 1550 file22: 0952 1552
2
by: christos panagiotou | last post by:
hi all I am trying to open some .raw files that represent images (256x256, 8 bit per pixel, no header) in a c++ program I cannot copy paste the module here as it uses a method from the VTK...
26
by: Simon | last post by:
I'm doing a survey. When do you think GNU/Linux will be ready for the average Joe? What obstacles must it overcome first?
4
by: hagai26 | last post by:
I have a hebrew text file, which I want to read in python I don't know which encoding I need to use & how I do that thanks, hagai
1
by: Hemanth | last post by:
Hello there, Could someone pls give me pointers (or examples) on how to use PHP (installed on a linux) to read & write MS Excel spreadsheets. So far I've been converting a spreadsheet to text...
6
by: Rajorshi Biswas | last post by:
Hi folks, Suppose I have a large (1 GB) text file which I want to read in reverse. The number of characters I want to read at a time is insignificant. I'm confused as to how best to do it. Upon...
0
by: dtsearch | last post by:
New release expands-through a .NET Spider API, to Linux, and to OpenOffice-dtSearch's ability to index over a terabyte of text in a single index, with indexed search time typically less than a...
9
by: 8anos | last post by:
Hello, I am new at the community and newbie at programming :) As you may know rapidshare provides a perl script for linux, to upload files at their servers. You can find the original scripts at...
1
by: shrimpy | last post by:
hi every one, i am new to python, and coz i want to write a handy command for my linux machine, to find a word in all the files which are under the current folder. the code is half done, but...
2
jwwicks
by: jwwicks | last post by:
C/C++ Programs and Debugging in Linux This tutorial will give you a basic idea how to debug a program in Linux using GDB. As you are aware Visual Studio doesn’t run on Linux so you have to use...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.