[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Importing mencoder into a bash script

Bob McGowan wrote:
andy wrote:
Andrew Sackville-West wrote:
On Mon, Jul 02, 2007 at 09:10:45PM +0100, andy wrote:
Hey folks

I'm lazy and want to call the mencoder routine from mplayer into a bash script I'm writing to automatically convert different video files into dvd format *.mpg files.

Anybody know how to call in just the routine without any unnecessary mplayer stuff?

ummm.... mencoder is a command-line program. just figure out your
options and use it like any other cli tool. it should "just work"

Hi Andrew

Yeah, it is a cli tool and I have traditionally used it as such at the vt and just entered it directly. However, in a shell script I have tried to do that but get the error message:

mencoder: command not found

This is because the command is not found in the PATH as seen *in the script*. Since you have 'traditionally used it', I presume you mean when you type 'mencoder' at a shell prompt, it runs.

I've played around with the PATH variable and interactive sub-shells to see how things work. The only thing I can see is if your script is setting the PATH to '/bin:/usr/bin', you'd lose mencoder if it were in /usr/local/bin, so either not explicitly setting the PATH in the script or being sure if you do that it includes the location of mencoder, is what you need to do (as you note, below).

I'm wondering if I need to explicitly set my path in the script file in order to call this function.

By the way, a note on terminology: in computerese, 'function' has a special meaning, usually for a bit of code that is not standalone but needs to be "called" from some other bit of code (shell "functions" are not quite the same thing, causing some confusion). I expect you were thinking of 'function' in the sense of 'what it does'. But, what scripts do is run 'programs', the word I'd encourage you to use.

Using the correct terminology helps reduce confusion and needless questions ;)

Thanks Bob for thinking through the problem I presented, as well as for the clarification on terminology. I am not a computer whiz but like to dabble here and there whenever I have that legendary "itch" to scratch. Nonetheless, I also obviously make some very silly (and embarrassing) errors.
Thanks for your patience :)



"If they can get you asking the wrong questions, they don't have to worry about the answers." - Thomas Pynchon, "Gravity's Rainbow"

Reply to: