LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-21-2007, 08:25 PM   #1
windisch
Member
 
Registered: Nov 2004
Location: Gahanna, Ohio, USA
Distribution: Fedora 9
Posts: 158

Rep: Reputation: 30
Question 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

Last edited by windisch; 03-24-2007 at 11:23 AM.
 
Old 03-24-2007, 11:23 AM   #2
windisch
Member
 
Registered: Nov 2004
Location: Gahanna, Ohio, USA
Distribution: Fedora 9
Posts: 158

Original Poster
Rep: Reputation: 30
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.
 
Old 03-26-2007, 08:52 PM   #3
windisch
Member
 
Registered: Nov 2004
Location: Gahanna, Ohio, USA
Distribution: Fedora 9
Posts: 158

Original Poster
Rep: Reputation: 30
Nevermind.
 
  


Reply

Tags
file, from, line, php, remove, sed


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
php - Read file line by line and change a specific line. anrea Programming 2 01-28-2007 01:43 PM
SED - replace text in file on specific line 3saul Linux - Software 1 03-04-2006 07:01 PM
sed question: remove decoration from each line Hivemind Linux - Software 1 01-18-2006 07:13 AM
[SOLVED] delete the end of each line in a file with sed angel115 Linux - Newbie 3 11-16-2005 04:41 PM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 06:12 AM


All times are GMT -5. The time now is 07:58 AM.

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