...

View Full Version : Edit Text Files & Reboot Linux Services



blackfish
03-26-2007, 01:22 PM
Hi,

I want to create a php script from which i want to call from a html file.

What i want to happen is 2 things.

1) Edit a text file and add data to it at the bottom of the file, once that has completed i want to reboot a linux service.

2) Edit a text file and place a "#" before the first character in lines 205 & 298 in that text file

I am a newbie to php scripting and i would like to learn. I am only 16 years of age and what to know this for a college project. :)

Many Thanks

BlackFish.

maghiel
03-26-2007, 03:06 PM
files:
http://nl2.php.net/manual/nl/ref.filesystem.php
look into the file functions in the php manual,
like fopen, file_get_contents, file_put_contents, etc, then come back for more questions :)

system commands:
http://nl2.php.net/manual/nl/function.exec.php
http://nl2.php.net/manual/nl/function.system.php
look into exec() and system() in the php manual :)

blackfish
03-30-2007, 10:08 AM
thanks,

i looked at that those docs and managed to get PHP to write data to a text file :D :)

but when it writes the data it does it like this (Please note that the dashes are irrelavent, they are there to seperate how i want the file to look!)

--------------------------------------------------------------------------
dogcatcheesefishorange
--------------------------------------------------------------------------

What i want the file to do is to write the data like this
--------------------------------------------------------------------------
dog
cat
cheese
fish
orange
--------------------------------------------------------------------------

if anyone coulde give me a howto or something i would be grateful

Many Thanks,

BlackFish

blackfish
03-31-2007, 10:39 PM
anyone?

Nightfire
03-31-2007, 10:56 PM
To add a newline in a text fle, use \n
eg:

$str = "dog\ncat\ncheese\nfish\norange\n";



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum