Greetings!
I'm writing a script that will take the contents of a text file that has several lines of user accounts and creates a shell script with chown commands for each user in that text file. My problem is that when it writes the shell script file it puts a line break after the colon in between $buffer and html. How do I prevent this from doing that?
Thanks, Rod
Code: -----------------------------------------------------------------------
$fhandle = fopen ("/scripts/thescript.sh" , "a");
$handle = fopen ("/scripts/mail_list.txt", "r");
while (!feof ($handle)) {
$buffer = fgets($handle, 1000);
fwrite ($fhandle, "chown $buffer:html /scripts/var/spool/mail/$buffer\n", 4096);
}
fclose ($handle);
fclose ($fhandle);
Chances are, $buffer has the line break on it when you read it in from the text file. Try striping off whitespace before you write...
while (!feof ($handle)) { $buffer = rtrim ( fgets($handle, 1000) ); fwrite ($fhandle, "chown $buffer:html
http://www.php.net/manual/en/function.rtrim.php
-- By-Tor.com It's all about the Rush http://www.by-tor.com
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php