You are not logged in.

#1 2015-04-27 11:48:11

richymartin
Member
Registered: 2015-04-27
Posts: 6

mpc doesn't like mpc add from script?? Strange issue

Hi All,

I've been scratching my head for a few days now, basically I have a script to grab the http stream link from a file, and output the result to 'mpc add'. It doesn't work! It only seems to work if the actual http link is in the initial command, not a grep.

#################################################
This works;
$:mpc add http://bbcmedia.ic.llnwd.net/stream/bbc … 3f5f3f9f66
#################################################
This doesn't works;
$:mpc add `grep -i "$1.*, "/var/local/bbc_radio/urls | head -1 | cut -d',' -f2`

$:mpc play
volume: 80%   repeat: off   random: off   single: off   consume: off
ERROR: problems decoding "http://bbcmedia.ic.llnwd.net/stream/bbc … be8fed94bb"16753f5f3f9f66


To prove the grep actually works;
$:echo `grep -i "$1.*, " /var/local/bbc_radio/urls | head -1 | cut -d',' -f2`
$:http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1_mf_p?s=1430119633&e=1430134033&h=25b6424be8fed94bb816753f5f3f9f66

Tried it another way, still doesn't work!
$:site=`grep -i "$1.*, " /var/local/bbc_radio/urls | head -1 | cut -d',' -f2` ; sudo mpc add $site
$:mpc play
volume: 80%   repeat: off   random: off   single: off   consume: off
ERROR: problems decoding "http://bbcmedia.ic.llnwd.net/stream/bbc … be8fed94bb"16753f5f3f9f66


I feel like I've missed something really obvious here sad any help would be much appreciated!

Thanks

Richy

Offline

#2 2015-04-27 12:15:13

Mercader1902
Member
Registered: 2014-09-01
Posts: 55

Re: mpc doesn't like mpc add from script?? Strange issue

richymartin wrote:
#################################################
This works;
$:mpc add http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1_mf_p?s=1430119633&e=1430134033&h=25b6424be8fed94       bb816    753f5f3f9f66
#################################################
$:mpc play
volume: 80%   repeat: off   random: off   single: off   consume: off
ERROR: problems decoding "http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1_mf_p?s=1430119633&e=1430134033&h=25b6424be8fed94     bb"16       753f5f3f9f66

There is a missed number (a 8, after the quote marks).

Don't forget to use the code tags. smile

Last edited by Mercader1902 (2015-04-27 12:16:10)

Offline

#3 2015-04-27 12:23:50

richymartin
Member
Registered: 2015-04-27
Posts: 6

Re: mpc doesn't like mpc add from script?? Strange issue

Sorry i think that's just the way it was truncated on my terminal window when it was resized.... full output below;

~ $ echo `grep -i "$1.*, " /var/local/bbc_radio/urls | head -1 | cut -d',' -f2`
http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1_mf_p?s=1430119633&e=1430134033&h=25b6424be8fed94bb816753f5f3f9f66

~ $ mpc add `grep -i "$1.*, " /var/local/bbc_radio/urls | head -1 | cut -d',' -f2`

~ $ mpc play
volume: 80%   repeat: off   random: off   single: off   consume: off
"RROR: problems decoding "http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1_mf_p?s=1430119633&e=1430134033&h=25b6424be8fed94bb816753f5f3f9f66

Last edited by richymartin (2015-04-27 12:49:21)

Offline

#4 2015-04-27 14:02:48

Mercader1902
Member
Registered: 2014-09-01
Posts: 55

Re: mpc doesn't like mpc add from script?? Strange issue

It works for me, it's really weird...

~/Pruebas   
$ mpc add  `grep -i "$1.*, " /home/ruben/Pruebas/urls | head -1 | cut -d',' -f2`           16:00
 ~/Pruebas   
$ mpc play                                                                                 16:00
bbc_radio_one
[playing] #1/7   0:00/0:00 (0%)
volume:  0%   repeat: off   random: off   single: off   consume: off

Offline

#5 2015-04-27 14:12:25

richymartin
Member
Registered: 2015-04-27
Posts: 6

Re: mpc doesn't like mpc add from script?? Strange issue

That's so strange.... What's your MPD version?

Offline

#6 2015-04-27 14:14:38

Mercader1902
Member
Registered: 2014-09-01
Posts: 55

Re: mpc doesn't like mpc add from script?? Strange issue

Music Player Daemon 0.19.9 and mpc 0.26-1.

Offline

#7 2015-04-27 14:30:33

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,804

Re: mpc doesn't like mpc add from script?? Strange issue

Are you both using the same shell? (Bash vs zsh)
What if you try using $(...) instead of `...`


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#8 2015-04-27 15:30:39

Mercader1902
Member
Registered: 2014-09-01
Posts: 55

Re: mpc doesn't like mpc add from script?? Strange issue

I use zsh but with bash it works for me too:

~   
$ bash                                                                                                                                         16:54
[ruben@filemon ~]$  mpc add  `grep -i "$1.*, " /home/ruben/Pruebas/urls | head -1 | cut -d',' -f2`
[ruben@filemon ~]$ mpc play
bbc_radio_one
[playing] #1/10   0:00/0:00 (0%)
volume:  0%   repeat: off   random: off   single: off   consume: off

Offline

#9 2015-04-27 21:00:50

richymartin
Member
Registered: 2015-04-27
Posts: 6

Re: mpc doesn't like mpc add from script?? Strange issue

ewaller wrote:

Are you both using the same shell? (Bash vs zsh)
What if you try using $(...) instead of `...`


I even just rebuilt arch and had the same problem.... however using $(..) instead of '...' works fine??!?! Which is brilliant, thank you... but why  does that work? whats the difference?

Thank you both for your efforts...

Offline

#10 2015-04-27 21:04:25

richymartin
Member
Registered: 2015-04-27
Posts: 6

Re: mpc doesn't like mpc add from script?? Strange issue

oh it doesn't sad

[root@alarmpi ~]# mpc add $(grep -i "$1.*, " /var/local/bbc_radio/urls | head -1 | cut -d',' -f2)
[root@alarmpi ~]# mpc play 1
http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1_mf_p?s=1430161173&e=1430175573&h=3c65c41ba0303373e746b8d870c9668b
[playing] #1/1   0:00/0:00 (0%)
volume: 96%   repeat: off   random: off   single: off   consume: off
[root@alarmpi ~]# mpc status
volume: 96%   repeat: off   random: off   single: off   consume: off
ERROR: Failed to decode http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio1_mf_ps=1430161173&e=1430175573&h=3c65c41ba0303373e746b8d870c9668b
[root@alarmpi ~]# 

Offline

Board footer

Powered by FluxBB