LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   bash script problem, using zenity to file select m2t file for mplayer but don't work? (https://www.linuxquestions.org/questions/linux-newbie-8/bash-script-problem-using-zenity-to-file-select-m2t-file-for-mplayer-but-dont-work-946532/)

davetesc 05-23-2012 05:45 PM

bash script problem, using zenity to file select m2t file for mplayer but don't work?
 
Using bash script I can use zenity to file select a video file, it returns file with full absolute path, I want to pass this to mplayer but get error message as if no filename passed to mplayer. Thought maybe mplayer quirk so tried mv $vidName video.m2t then mplayer video.m2t as quick work around but that doesn't work either. Think I'm missing something obvious but have tried all manner of quoting and brackets.
Any suggestions greatly appreciated.

Davetesc

colucix 05-23-2012 06:13 PM

Welcome to LinuxQuestion, Davetesc!

Difficult to tell what's the issue without looking at your script or the relevant lines of it. Something like this should work straightforward:
Code:

file="$(zenity  --title='Select a video to watch' --file-selection)"
mplayer "$file"

Does the file you selected contain spaces in its name? If this is the case, what if you select a file without spaces?

davetesc 05-26-2012 06:49 PM

Thanks for that Colucix, I figured out what I was doing wrong a couple of hours before I got your msg. In my hurry to do something interesting with bash I breezed through the chapter on variables in the ABS guide missing the bit that said "DON'T put spaces arround the = when assigning variables! Oooops 2 months wasted tearing my hair out! I took out the space and added backticks , the line works as expected now.

vidN=`zenity --file-selection --filename=$CurrentDir`
echo "$vidN"
mplayer -fs "$vidN"

Had I not figured this out your post would have tipped me off so many, many thanks. Davetesc


All times are GMT -5. The time now is 04:26 PM.