2

I have mplayer installed and I want to create a simple shell script that runs in bash and executes mplayer * in the current directory. So, how to call upon mplayer in the shell script?

1

You should use mplayer command in your script in the same way as you use it in terminal. For example:

#!/bin/bash

# some bash code here

cd /path/to/where/you/want/to/start/mplayer
mplayer *

# more bash code here

See also: man mplayer.

3
  • Normally, this won't work, because in most distros out there, the current directory is not in $PATH. Youwant to use ./mplayer instead of mplayer – Bonsi Scott Nov 1 '13 at 14:27
  • @BonsiScott Well, I specified: in the same way as you use it in terminal. – Radu Rădeanu Nov 1 '13 at 14:43
  • 1
    @BonsiScott Why on earth would mplayer be installed in the current directory? It's usually in the PATH. The question requests running mplayer with a certain directory current, not running an mplayer executable in a particular directory. – Gilles 'SO- stop being evil' Nov 1 '13 at 23:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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