You are not logged in.
Pages: 1
Hello all.
I seem to have run into a brick wall with a script problem concerning MPlayer. A while back I enlisted the help of some of the users here in creating a bash script that would allow me to run a mplayer playlist more or less shuffled.
[Solved] Mplayer - Is this possible without a GUI?
Well.. the issue is this. A couple weeks back I decided I was going to do a clean install of Arch, and as of yesterday I went ahead and did. After reinstalling, copying over my backup user config files, etc., I noticed that it was not working anymore.
This was my slightly modified version that I had changed over the months
#!/bin/bash
pls=/tmp/$RANDOM.pls
echo "$1" >$pls
find * -type f ! -name "*.srt"|grep -v "$1"|shuf>>$pls
mplayer -playlist $pls
rm $pls
This, and the original, keep trying to append the filenames in the playlist as if they were located in the /tmp directory.
ie;
original
Playing /tmp/./test.flv.
Cannot open file '/tmp/./test.flv': No such file or directory
Failed to open /tmp/./test.flv.
or
modified
Playing /tmp/test.flv.
Cannot open file '/tmp/test.flv': No such file or directory
Failed to open /tmp/test.flv.
After making the playlist generate in the same folder, the script was almost there. The continued problem was that grep was no longer filtering out the initial media file used to launch the playlist, and I was ending up with it being listed twice. I even tried passing the "$1" variable to find's exclude parameters with no luck.
#!/bin/bash -x
#/usr/local/bin/mpscur
pls=$RANDOM.pls
echo "$1" >$pls
find * -type f ! -name "*pls" ! -name "*srt"|grep -v "$1"|shuf>>$pls
mplayer -playlist $pls
#rm $pls
and
#!/bin/bash -x
#/usr/local/bin/mpscur
pls=$RANDOM.pls
echo "$1" >$pls
find * -type f ! -name "*pls" ! -name "*srt" ! -name "$1"|shuf>>$pls
mplayer -playlist $pls
#rm $pls
Neither works. You can run the script from an additional script to see the terminal output like so...
#!/bin/bash
xterm -hold -e mpscur "$1"
Just launch any media file from a directory containing music/video using the above xterm script to see what I mean. I hadn't updated Arch for about 3-4 months, but I was still surprised to find that some kind of syntax had changed so drastically as to break this very simple job.
Any ideas why I can't...
- Generate the playlist anywhere other than the directory where the script is launched from (path issues).
- Properly filter out the originally launched file ("$1") from being added to the playlist's shuffle addition entries.
Offline
Sorry for the bump, but I didn't know who to PM. Could a moderator migrate this thread to the 'Programming and Scripting' sub-board?
Offline
Just use the "Report" button.
To know or not to know ...
... the questions remain forever.
Offline
Moving...
# edit: a quick hack would be to add a `cd /tmp` to the start of the script...
Offline
Well... if I change directories to /tmp, it won't list the rest of the files without a hard-coded cd back to the original directory.
Any idea why the pipe to grep isn't removing the first file from the shuffled list additions? It just seems strange that even the original script posted by kokoko3k doesn't work anymore. What's changed in the base system, or did I screw up my install somehow?
Offline
Well... if I change directories to /tmp, it won't list the rest of the files without a hard-coded cd back to the original directory.
If you use an absolute path in the find command, it will work fine: `find ~/*`, eg.
Any idea why the pipe to grep isn't removing the first file from the shuffled list additions? It just seems strange that even the original script posted by kokoko3k doesn't work anymore. What's changed in the base system, or did I screw up my install somehow?
It works for me. As to why it worked previously, I have no idea.
Offline
Since Linux doesn't support going to the root of any drive due to the way it mounts other partitions, I can't do anything like the windows equivalent of "cd \" can I?
Because, I had also created a previously working script where I had all my media in several folders on the root of a mounted drive (only one directory deep).
#!/bin/bash -x
pls=$RANDOM.pls
readlink -f "$1" >../$pls
cd ..
find "`pwd`" -type f ! -name "*pls" ! -name "*srt" ! -name "$1"|shuf >>$pls
mplayer -playlist $pls
rm $pls
Can anyone tell me if if this or the (non-grep) one above in post #1 works for them?
Last edited by *nixer (2013-09-11 23:14:52)
Offline
Not to be a bore, but did anyone verify if my version worked for them? I for the life of me can't figure out what changed after the reinstall.
Offline
Pages: 1