PDA

View Full Version : HELP!! CRAZY!! paths with special characters



kakyoism
November 1st, 2008, 11:36 PM
In a bash script, I wanted to use mencoder to extract specific part of a movie. See below

#! /bin/sh

fn=$1
st=$2
et=$3

echo $fn

mencoder -ss $st -endpos $et -ovc copy -oac copy $fn -o out.avi


However, when the input path ($fn) contains "-" or SPACE, mencoder just can't get the path right.

I tried to add double-quotation marks to it, in the script or on the fly with the input argument; neither worked.


This problem has driven me crazy for ages. Every time I thought double-quoting could clear my way it just blows here and there...


Help!!!

unutbu
November 2nd, 2008, 12:42 AM
Have you tried


#! /bin/sh

fn=$1
st=$2
et=$3

echo $fn
mencoder -ss "$st" -endpos "$et" -ovc copy -oac copy "$fn" -o out.avi
And also double-quoting the filename on the command line? I think you need to do both.

kakyoism
November 2nd, 2008, 01:38 AM
I did! It didn't work!

ghostdog74
November 2nd, 2008, 01:52 AM
you will have to put quotes when you pass arguments to your script


./myshellscript.sh "first argument" "second"

kakyoism
November 2nd, 2008, 03:56 AM
Thx, but I did add quotes to my argument as you said....
That's why I'm asking...

ad_267
November 2nd, 2008, 04:00 AM
Try this:


#! /bin/sh

fn="$1"
st="$2"
et="$3"

echo $fn
mencoder -ss "$st" -endpos "$et" -ovc copy -oac copy "$fn" -o out.avi

and then use quotes when calling the script.

ghostdog74
November 2nd, 2008, 04:00 AM
don't just say "it doesn't work". Show us how is it that is doens't work. Errors, input samples, output formats , what you did, how you execute etc... anything that will help us to help you. we are not psychics.

kakyoism
November 2nd, 2008, 04:16 AM
Sorry guys, I thought this would be an obvious problem to you experts so I wasn't careful enough to give all the data.

BTW: my locale is Mandarin. Even my original script works with paths containing Mandarin characters, but here in the example there are Japanese characters, then even the revised version does not work!

This is my output with the revised script


<Script>
----------
fn=$1
st=$2
et=$3

echo $fn
mencoder -ss "$st" -endpos "$et" -ovc copy -oac copy "$fn" -o out.avi


<Output>
----------------------------------------
kakyo@kakyo-laptop:/media/USB-DOWNLOAD/torrent/New Comer 我的电影$ cut_movie.sh "山崎舞 - New Comer.avi" "00:00:00" "00:31:00"

山崎舞 - New Comer.avi
MEncoder 2:1.0~rc2-0ubuntu13+medibuntu1 (C) 2000-2007 MPlayer Team
CPU: Intel(R) Core(TM)2 Duo CPU T5550 @ 1.83GHz (Family: 6, Model: 15, Stepping: 13)
CPUflags: Type: 6 MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.
File not found: '山崎舞 - New Comer.avi'
Failed to open 山崎舞 - New Comer.avi.
Cannot open file/device.


BTW: my locale is Mandarin. Even my original script works with paths containing Mandarin characters, but here in the example there are Japanese characters, then even the revised version does not work!

geirha
November 13th, 2008, 10:40 AM
Could you add a line

ls "$fn" too to see if ls finds the file? If it does, it's possibly a problem with mencoder.