LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   PHP Remove Line From Shoutcast Playlist File. Sed? (http://www.linuxquestions.org/questions/programming-9/php-remove-line-from-shoutcast-playlist-file-sed-539491/)

windisch 03-21-2007 09:25 PM

PHP Remove Line From Shoutcast Playlist File. Sed?
 
I have a shoutcast server, and I'm trying to add a piece to my web interface. What I'm looking at doing is removing a line from the playlist. The code works on a test playlist. But when I try it on the real playlist, it fails, because the file is being read by the shoutcast server.

PHP Code:

<?php
$song
=$_GET['song'];
$song=$song 1;
$filename "/home/draco/shoutcast/transcode/MythMusic.alw"// File which holds all data
$rowToDelete $song// This is line need to be deleted

$arrFp file$filename ); // Open the data file as an array
$numLines count$arrFp ); // Count the elements in the array

$fp fopen$filename"w" ); // Open the file for writing
for($i=0$i<$numLines$i++) // Overwrite the content except the line to be deleted
{
    if(
$i != ($rowToDelete-1) )
    
fwrite($fp$arrFp[$i]);
}
fclose$fp ); // Close the file
?>

I have a bash script (designed with the help of good people from this forum) that can use sed and remove a line from the same file when in use, so I'm assuming that I can do something similar with PHP.

Anyone have a suggestion?

Thanks,
Adam

windisch 03-24-2007 12:23 PM

Just checking in. Anyone have a suggestion? Or is what I'm trying to do impossible? Can I call a bash script that calls sed to remove the line? Any help would be appreciated.

windisch 03-26-2007 09:52 PM

Nevermind.


All times are GMT -5. The time now is 11:45 PM.