2015-03-13 187 views
0

我不能讓這個腳本工作,返回第一個elif的錯誤,任何人都可以幫我嗎?CentOS Shell腳本elif錯誤

#!/bin/sh 

/var/www/vhosts/website/httpdocs/ffmpeg -i $1$2 -s qvga -vcodec libx264 -acodec aac -strict experimental -ab 64k -ac 2 -ar 44100 -f mp4 -b 384k -r 25 -movflags faststart $1com_$2 
if [ "$6" = "Portrait" ] 
then 
/var/www/vhosts/website/httpdocs/ffmpeg -i $1$3 -vf 'transpose=1' -y -strict -2 $1$4 

elif [ "$6" = "LandscapeRight" ] 
then 
/var/www/vhosts/website/httpdocs/ffmpeg -i $1$3 -vf 'vflip [a]; [a] hflip' -strict -2 -y $1$4 

elif [ "$6" = "PortraitUpsideDown" ] && [ "$7" = "Iphone" ] 
then 
/var/www/vhosts/website/httpdocs/ffmpeg -i $1$3 -vf -filter_complex 'transpose=2; vflip [a]' -y -strict -2 $1$4 

elif [ "$6" = "PortraitUpsideDown" ] && [ "$7" = "Android" ] 
then 
/var/www/vhosts/website/httpdocs/ffmpeg -i $1$3 -vf 'transpose=3' -y -strict -2 $1$4 
fi 


/var/www/vhosts/website/httpdocs/ffmpeg -itsoffset -1 -i $1$4 -vcodec mjpeg -vframes 1 -an -f rawvideo -strict -2 $1$5 
echo $5 

和IM調用像這樣的文件:

sh test.sh /var/www/vhosts/website/httpdocs/public/upload/album_detail_files/6501/ 201503131239571426307580.mp4 com_201503131239571426307580.mp4 LandscapeLeft_com_201503131239571426307580.mp4 1_20150313123957snap.jpg LandscapeLeft Iphone 

的錯誤是:

test.sh: line 7: syntax error near unexpected token `elif' 
'est.sh: line 7: `elif [ "$6" = "LandscapeRight" ] 

Thans很多;)

回答

0
test.sh: line 7: syntax error near unexpected token `elif' 
'est.sh: line 7: `elif [ "$6" = "LandscapeRight" ] 

如何看單引號是覆蓋第一個字符?這表明你有CRLF行結束,您的實際代碼是:

elif [ "$6" = "LandscapeRight" ]\r 

嘗試運行腳本通過dos2unix

+0

感謝了很多人;) – kanazaca 2015-03-13 13:00:11