LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Pasting a block of commands, handling delayed programs (ffmpeg) (http://www.linuxquestions.org/questions/linux-newbie-8/pasting-a-block-of-commands-handling-delayed-programs-ffmpeg-714742/)

anonguy9 03-26-2009 10:52 PM

Pasting a block of commands, handling delayed programs (ffmpeg)
 
I'm not sure how to search for this. I've tried some stuff off the top of my head but without any luck.

I have some medium sized scripts which I want to be able to paste in bulk into a terminal.

However, these scripts will halt when ffmpeg is run. Nothing after that pasted command is used. This is because ffmpeg sits there and spins its wheels.

- If put into a script, everything would work fine.
- If the copy-and-paste did each ffmpeg in turn it would be ok.
- But is there a sensible way for me to modify my code so that it's more paste friendly?

Something like this non-functioning code perhaps?:

Code:

echo other stuff
echo other stuff
ffmpeg foo&&\
echo other stuff
ffmpeg foo&&\
echo other stuff
ffmpeg foo&&\
echo other stuff


jschiwal 03-27-2009 12:14 AM

Why not paste it into a script?

e.g.
cat >script
<PRESS PASTE HERE>
..
..
<THEN PRESS CTRL-D>

anonguy9 03-27-2009 09:12 AM

Quote:

Why not paste it into a script?
Because that's more keystrokes than I want. =)

-

I did some thinking, and I realised that ffmpeg is running in an interactive mode (q to quit). This explains things. So ffmpeg is trying to be smart and it sees that I'm at a commandline.

This message from Aug 2006 says that there is no way to force non-interactive mode. So far I haven't been able to confirm or deny that.

I'll check with the ffmpeg people about this. (link / thread)


So I guess the only solution would be to have some kind of cat helper-prompt thing which will accept pasted input and will run that script.

Code:

TEMP=/tmp/test.$PPID && cat - > $TEMP && bash $TEMP && rm -f $TEMP
If I could wrap that into my actual physical bash prompt, that would be pretty sweet. I'll research that for a bit.

anonguy9 03-27-2009 01:31 PM

AHA!

Appending this to the end of an interactive program will force it back into non-interactivity.

Code:

>/dev/null 2>/dev/null </dev/null
So now I can paste blocks of code with multiple non-interactive programs. Awesome!


All times are GMT -5. The time now is 11:15 AM.