Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a script that starts pianobar (pandora player) and autoloads into tty2 after booting. I'm running Ubuntu Precise 12.04.

it's a pretty simple script:

    #!bin/bash
    sleep 5
    echo "2" | pianobar

This works, it selects station 2 and begins playing... but when I try to type in commands it doesn't work (like pushing "p" for pause.) It'll show the letter for a second, then hide it. If I try to exit with ctrl+z it just sits there and I can't use it at all.

If I run this it works fine but doesn't auto-select the second station:

    #!bin/bash
    sleep 5
    pianobar

Is there anyway to write this so it will automatically input "2" and then allow me to control from there? Or am I stuck with having to select 2 every time I boot up?

EDIT:

I modified it to this:

    #!bin/bash
    sleep 5
    { echo 2 ; cat ; } | pianobar

and it does the exact same thing as just "echo 2 | pianobar"

"Isn't there an option to pianobar to start with a default station"

I would of thought so, but I can't find a command for a default setting when I do "man pianobar"

When I open the program, it does a login and then the program starts with "Select station:" I'd like for it to automatically go into the 2nd station.

share|improve this question

1 Answer 1

What happens is that you link the stdout of echo with the stdin of pianobar, but then echo exits and the stream is gone. Try that:

{ echo 2 ; cat ; } | pianobar

My main question, however, would be -- what are you trying to achieve? Why not start just the pianobar? Isn't there an option to pianobar to start with a default station, if that's the problem?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.