Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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? I am a newbie to linux and would like detailed instructions.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer
    
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 Nov 1 '13 at 23:41

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.