Find the answer to your Linux question:
Results 1 to 4 of 4
JK Says: Here is a one-liner bash function that will allow you to stream any iheartradio station by typing: iheartradio function iheartradio { mplayer -quiet $(wget -O -q hxxp://p2.$1.ccomrcdn.com/player/player_dispatcher.html?section=radio&action=listen ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2011
    Posts
    3

    I need help correcting a bash script



    JK Says:

    Here is a one-liner bash function that will allow you to stream any iheartradio station by typing:
    iheartradio
    function iheartradio { mplayer -quiet $(wget -O -q hxxp://p2.$1.ccomrcdn.com/player/player_dispatcher.html?section=radio&action=listen _live | sed -n s|.*primary_location=\\(rtmp://[^\"]*\)\.*|\1|p) -novideo >& /dev/null; }
    Hello i've found in time many helpful stuff linked with this forum thanks to google, but i really need your help with this one. For some reason i can't really understand scripting language. Could anyone please make this work for me?
    I'll try to explain what i'm doing here, and it seems that i'll have to replace all links with hxxp because of the 15 post limit if you don't mind.

    There's this flash radio site, and i want to access it from the terminal through a simple command.
    The rtmp:// stream changes every hour or something like that. This stream can always be found into this xml page hxxp://p2.wrzx-fm.ccomrcdn.com/player/player_dispatcher.hml?section=radio&action=listen _live

    the command that plays fine the radio in the terminal is: mplayer "rtmp://url" -novideo
    so if it updates, i have to open the xml page again and again and copy the rtmp link to play.

    aparently this guy figured out this script that should grab the rtmp url and run it in mplayer through a single command, but i'm an idiot and have no knowledge why it's not working

    what i do know is that i need to put #!/bin/bash line at the beginning of my script and that i need to make it executable in order to actually run it, but it's not working

    here's my script:
    (i have replaced his $1 from the script line with wrzx-fm because that's the radio's name btw)

    #!/bin/bash
    function iheartradio { mplayer -quiet $(wget -O -q hxxp://p2.wrzx-fm.ccomrcdn.com/player/player_dispatcher.html?section=radio&action=listen _live | sed -n s|.*primary_location=\\(rtmp://[^\"]*\)\.*|\1|p) -novideo >& /dev/null; }
    PC:~/Desktop$ chmod u+x iheartradio.sh
    PC:~/Desktop$
    ok, and now to run the thing in the terminal:

    PC:~/Desktop$ iheartradio
    iheartradio: command not found
    PC:~/Desktop$ iheartradio.sh
    iheartradio.sh: command not found
    PC:~/Desktop$ ./iheartradio.sh
    PC:~/Desktop$ /.iheartradio.sh
    bash: /.iheartradio.sh: No such file or directory
    PC:~/Desktop$ .iheartradio.sh
    .iheartradio.sh: command not found
    PC:~/Desktop$ '/home/tzily/Desktop/iheartradio.sh'
    PC:~/Desktop$ sudo iheartradio.sh
    [sudo] password for tzily:
    sudo: iheartradio.sh: command not found
    PC:~/Desktop$
    I'm trying hard to run it, but i assume the script needs something...
    this might look pathetic for some experienced fellows around here, but i'm new to this and if i don't get it right, i can't sleep tonoght please could someone correct and test this for me? Many thanks in advance. I'll be forever grateful!!!

  2. #2
    Just Joined!
    Join Date
    Aug 2011
    Posts
    3
    thank you
    someone at ubuntuforums helped me

    if anyone googles, a working script is

    Code:
    #!/bin/bash
    { mplayer -quiet $(wget -O - -q "hxxp://p2.wrzx-fm.ccomrcdn.com/player/player_dispatcher.html?section=radio&action=listen_live" | sed -n "s|.*primary_location=\"\(rtmp://[^\"]*\)\".*|\1|p") -novideo >& /dev/null; }
    the problem was with the quotes " " and with a -
    Last edited by tzily; 08-20-2011 at 01:34 PM.

  3. #3
    Just Joined!
    Join Date
    Sep 2011
    Location
    rebro, Sweden
    Posts
    17
    Good sense to post the solution

    Thanx

    * I dont think you are a idiot, even if you wrote that you where
    Last edited by Hyp0tez; 09-19-2011 at 09:23 AM. Reason: Disclaiming "Idiocy"

  4. #4
    Just Joined!
    Join Date
    Aug 2011
    Posts
    3
    why thank you!
    i'm always against people finding answers and skipping their threads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •