CentOS Shell 脚本 elif 错误
CentOS Shell Scripting elif error
我无法让这个脚本工作,returns 第一个 elif 出错,有人能帮我吗?
#!/bin/sh
/var/www/vhosts/website/httpdocs/ffmpeg -i -s qvga -vcodec libx264 -acodec aac -strict experimental -ab 64k -ac 2 -ar 44100 -f mp4 -b 384k -r 25 -movflags faststart com_
if [ "" = "Portrait" ]
then
/var/www/vhosts/website/httpdocs/ffmpeg -i -vf 'transpose=1' -y -strict -2
elif [ "" = "LandscapeRight" ]
then
/var/www/vhosts/website/httpdocs/ffmpeg -i -vf 'vflip [a]; [a] hflip' -strict -2 -y
elif [ "" = "PortraitUpsideDown" ] && [ "" = "Iphone" ]
then
/var/www/vhosts/website/httpdocs/ffmpeg -i -vf -filter_complex 'transpose=2; vflip [a]' -y -strict -2
elif [ "" = "PortraitUpsideDown" ] && [ "" = "Android" ]
then
/var/www/vhosts/website/httpdocs/ffmpeg -i -vf 'transpose=3' -y -strict -2
fi
/var/www/vhosts/website/httpdocs/ffmpeg -itsoffset -1 -i -vcodec mjpeg -vframes 1 -an -f rawvideo -strict -2
echo
我这样调用文件:
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 [ "" = "LandscapeRight" ]
非常感谢 ;)
test.sh: line 7: syntax error near unexpected token `elif'
'est.sh: line 7: `elif [ "" = "LandscapeRight" ]
看到单引号是如何覆盖第一个字符的了吗?这表明你有 CRLF 行结尾,你的实际代码是:
elif [ "" = "LandscapeRight" ]\r
通过 dos2unix
尝试 运行 您的脚本
我无法让这个脚本工作,returns 第一个 elif 出错,有人能帮我吗?
#!/bin/sh
/var/www/vhosts/website/httpdocs/ffmpeg -i -s qvga -vcodec libx264 -acodec aac -strict experimental -ab 64k -ac 2 -ar 44100 -f mp4 -b 384k -r 25 -movflags faststart com_
if [ "" = "Portrait" ]
then
/var/www/vhosts/website/httpdocs/ffmpeg -i -vf 'transpose=1' -y -strict -2
elif [ "" = "LandscapeRight" ]
then
/var/www/vhosts/website/httpdocs/ffmpeg -i -vf 'vflip [a]; [a] hflip' -strict -2 -y
elif [ "" = "PortraitUpsideDown" ] && [ "" = "Iphone" ]
then
/var/www/vhosts/website/httpdocs/ffmpeg -i -vf -filter_complex 'transpose=2; vflip [a]' -y -strict -2
elif [ "" = "PortraitUpsideDown" ] && [ "" = "Android" ]
then
/var/www/vhosts/website/httpdocs/ffmpeg -i -vf 'transpose=3' -y -strict -2
fi
/var/www/vhosts/website/httpdocs/ffmpeg -itsoffset -1 -i -vcodec mjpeg -vframes 1 -an -f rawvideo -strict -2
echo
我这样调用文件:
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 [ "" = "LandscapeRight" ]
非常感谢 ;)
test.sh: line 7: syntax error near unexpected token `elif'
'est.sh: line 7: `elif [ "" = "LandscapeRight" ]
看到单引号是如何覆盖第一个字符的了吗?这表明你有 CRLF 行结尾,你的实际代码是:
elif [ "" = "LandscapeRight" ]\r
通过 dos2unix