Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    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:
    function iheartradio { mplayer -quiet $(wget -O -q hxxp://p2.$ _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:// _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)

    function iheartradio { mplayer -quiet $(wget -O -q hxxp:// _live | sed -n s|.*primary_location=\\(rtmp://[^\"]*\)\.*|\1|p) -novideo >& /dev/null; }
    PC:~/Desktop$ chmod u+x
    ok, and now to run the thing in the terminal:

    PC:~/Desktop$ iheartradio
    iheartradio: command not found
    PC:~/Desktop$ command not found
    PC:~/Desktop$ ./
    PC:~/Desktop$ /
    bash: / No such file or directory
    PC:~/Desktop$ command not found
    PC:~/Desktop$ '/home/tzily/Desktop/'
    PC:~/Desktop$ sudo
    [sudo] password for tzily:
    sudo: command not found
    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
    thank you
    someone at ubuntuforums helped me

    if anyone googles, a working script is

    { mplayer -quiet $(wget -O - -q "hxxp://" | 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
    rebro, Sweden
    Good sense to post the solution


    * 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. $spacer_open
  5. #4
    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