This is a cross post from Programming because of no replies.
Only thing that has changed is the log file is now /dev/ttyu1 and I cat from /dev/ptyu1 instead of tailing the log file. This completely removes constant harddrive writing and should solve one huge problem I was looking at (Damnsmalllinux based OS from flash. Too many writes to a flash drive = bad), though OSX gui does not handle named pipes at all, so I used a psuedo-terminal. DSL should should handle named pipes from gui well enough, or I will use a peusdo-terminal pair there as well.
---------------
I am trying to take the output of a GUI program (VLC message buffer saved to a log file) and format it for command line display.
The file is saved to ~/Logs/vlc-log.txt.
The output to the log is filled with alot of pointless info, but I broke down the useful info (this is the output of streaming radio connections, local files are different, but that's a problem for another day)
The macosx debug lines tell me when the file/stream was opened and closed (Play, Pause, Stop, change song), which might tie in to getting this to output the correct info depending on streaming radio or local file/mp3. But less on that for now.
The parts I want for now are:
access_http debug: Icy-Name: [ DigitalGunfire.com ] - Long Range, Hard Hitting!
access_http debug: Meta-Info: icy-url: http://www.digitalgunfire.com
access_http debug: New Title=God Module - Ever After
Of course, the Stream name, url, and title change depending on the stream and song being played.
I do not want the
main debug: - 'Title' = '[ DigitalGunfire.com ] - Long Range, Hard Hitting!'
main debug: - 'Now Playing' = 'God Module - Ever After'
because the main debug- title line is also used for mp3's and gets sent on every new "Now Playing" so any output I get has the stream's name added repetitively.
Now Playing also has lots of single quotes that I figure would be harder to strip out for formatting the info.
What I currently have is
tail -n15 -f ~/Logs/vlc-log.txt | fgrep -e "New Title" -e "Icy-Name" -e "icy-url"
Giving me an output of
I had to resort to fgrep for the same reason I can not figure out how to format the output in the first place. With tail + (f)grep, I cannot pipe it to a new instance of grep or any other program and get output.
Now, what I want to do is strip "access_http debug: " from each line of output, and change "Icy-Name: ", "Meta-Info: icy-url: ", and "New Title=" to "Stream: ", "@ ", and "Now Playing: "
I have tried using sed, cut, and a grep using -v and -o (invert matching and Show only the part matching pattern, which don't seem to work together). But because I can't get any output from tail piped into grep piped into ANYTHING else, I'm stuck.
Currently, I am trying to do this using just bash and standard commands, but want to expand this program. As I have mentioned, I also need to do this to VLC's mp3 output, but if I get help with this, I can do that one (Same commands, different grepped patterns). I would also like to get this program to recognize the difference between the mp3 and streaming radio output and display only the correct type of formatted output. (As well as recognizing id3v1 and id3v2 tags to avoid duplicate entries). Past this, it would turn into a GUI program, etc.
If a mod feels this belongs in the OS->Linux forum, by all means, but I figured that this would fall under programming since bash is a programming language
Oh, and I am on OSX if it matters.
Only thing that has changed is the log file is now /dev/ttyu1 and I cat from /dev/ptyu1 instead of tailing the log file. This completely removes constant harddrive writing and should solve one huge problem I was looking at (Damnsmalllinux based OS from flash. Too many writes to a flash drive = bad), though OSX gui does not handle named pipes at all, so I used a psuedo-terminal. DSL should should handle named pipes from gui well enough, or I will use a peusdo-terminal pair there as well.
---------------
I am trying to take the output of a GUI program (VLC message buffer saved to a log file) and format it for command line display.
The file is saved to ~/Logs/vlc-log.txt.
The output to the log is filled with alot of pointless info, but I broke down the useful info (this is the output of streaming radio connections, local files are different, but that's a problem for another day)
Code:
main debug: `http://radio2-us.digitalgunfire.com:9000/' gives access `http' demux `' path `radio2-us.digitalgunfire.com:9000/'
main debug: creating demux: access='http' demux='' path='radio2-us.digitalgunfire.com:9000/'
main debug: creating access 'http' path='radio2-us.digitalgunfire.com:9000/'
access_http debug: http: server='radio2-us.digitalgunfire.com' port=9000 file='/
main debug: net: connecting to radio2-us.digitalgunfire.com port 9000
macosx debug: input has changed, refreshing interface
access_http debug: Icy-Name: [ DigitalGunfire.com ] - Long Range, Hard Hitting!
access_http debug: Meta-Info: icy-url: http://www.digitalgunfire.com
main debug: creating demux: access='http' demux='mp3' path='radio2-us.digitalgunfire.com:9000/'
main debug: meta information:
main debug: - 'Title' = '[ DigitalGunfire.com ] - Long Range, Hard Hitting!'
main debug: `http://radio2-us.digitalgunfire.com:9000/' successfully opened
access_http debug: New Title=God Module - Ever After
main debug: meta information:
main debug: - 'Title' = '[ DigitalGunfire.com ] - Long Range, Hard Hitting!'
main debug: - 'Now Playing' = 'God Module - Ever After'
macosx debug: input has stopped, refreshing interface
The macosx debug lines tell me when the file/stream was opened and closed (Play, Pause, Stop, change song), which might tie in to getting this to output the correct info depending on streaming radio or local file/mp3. But less on that for now.
The parts I want for now are:
access_http debug: Icy-Name: [ DigitalGunfire.com ] - Long Range, Hard Hitting!
access_http debug: Meta-Info: icy-url: http://www.digitalgunfire.com
access_http debug: New Title=God Module - Ever After
Of course, the Stream name, url, and title change depending on the stream and song being played.
I do not want the
main debug: - 'Title' = '[ DigitalGunfire.com ] - Long Range, Hard Hitting!'
main debug: - 'Now Playing' = 'God Module - Ever After'
because the main debug- title line is also used for mp3's and gets sent on every new "Now Playing" so any output I get has the stream's name added repetitively.
Now Playing also has lots of single quotes that I figure would be harder to strip out for formatting the info.
What I currently have is
tail -n15 -f ~/Logs/vlc-log.txt | fgrep -e "New Title" -e "Icy-Name" -e "icy-url"
Giving me an output of
Code:
access_http debug: Icy-Name: [ DigitalGunfire.com ] - Long Range, Hard Hitting!
access_http debug: Meta-Info: icy-url: http://www.digitalgunfire.com
access_http debug: New Title=Hocico - Ladykiller (In Cold Blood)
I had to resort to fgrep for the same reason I can not figure out how to format the output in the first place. With tail + (f)grep, I cannot pipe it to a new instance of grep or any other program and get output.
Now, what I want to do is strip "access_http debug: " from each line of output, and change "Icy-Name: ", "Meta-Info: icy-url: ", and "New Title=" to "Stream: ", "@ ", and "Now Playing: "
I have tried using sed, cut, and a grep using -v and -o (invert matching and Show only the part matching pattern, which don't seem to work together). But because I can't get any output from tail piped into grep piped into ANYTHING else, I'm stuck.
Currently, I am trying to do this using just bash and standard commands, but want to expand this program. As I have mentioned, I also need to do this to VLC's mp3 output, but if I get help with this, I can do that one (Same commands, different grepped patterns). I would also like to get this program to recognize the difference between the mp3 and streaming radio output and display only the correct type of formatted output. (As well as recognizing id3v1 and id3v2 tags to avoid duplicate entries). Past this, it would turn into a GUI program, etc.
If a mod feels this belongs in the OS->Linux forum, by all means, but I figured that this would fall under programming since bash is a programming language
Oh, and I am on OSX if it matters.