脚本-1 findFile
configPath=$1
configContent=(`cat $configPath`)
cfiglen=${#configContent[@]}
path=$2
remoteCodePath=$3
cd $path
fileArray=(`ls | cut -d "." -f1`)
len=${#fileArray[@]}
index=0
for ((i=0;i<$len;i=i+1))
do
if(($index == $cfiglen));
then
index=0;
fi
if(($index != $cfiglen));
then
ssh root@${configContent[index]} /lekan/shell/transcode ${fileArray[i]} $remoteCodePath
echo ${configContent[index]} "------" ${fileArray[i]}
index=$(($index+1))
fi
done
---------------------------------------
脚本-2 transcode
fileName=$1
codePath=$2
if [ $fileName != "" ]; then
cd $codePath
videoId=`source ./fileRule getVideoId $fileName`
type=`source ./fileRule getType $fileName`
echo "fileName="$fileName",type="$type",videoId="$videoId
filePath="/lekan/"
ssmPath=$filePath`source ./fileRule getVideoPath $fileName`video.ssm/
mp4Path=$filePath`source ./fileRule getVideoPath $fileName`
imagePath=$filePath`source ./fileRule getImagePath $fileName`
echo "ssmPath="$ssmPath
echo "mp4Path="$mp4Path
echo "imagePath="$imagePath
urlPath="http://192.168.0.48:9001/transcode.jsp"
sta=`curl --data "operate=1&fileName=$fileName" $urlPath`
if [ "$sta" == "0" ]; then
echo $fileName "trancode error"
elif [ "$sta" == "1" ]; then
echo "start transcode filename=$fileName"
if [ -d "$ssmPath" ];then
echo "ssmPath exist"
else
mkdir -p "$ssmPath"
fi
if [ -d "$imagePath" ]; then
echo "imagePath exist"
else
mkdir -p "$imagePath"
touch $imagePath"screenshot_data.xml"
source ./cxml $imagePath
fi
else
echo "unknown error"
fi
fi
---------------------------------------
脚本-3 fileRule
fileNamep=$2
function getType(){
if [ `expr index $fileNamep 'M'` \> 0 ]; then
echo 4
fi
if [ `expr index $fileNamep 'E'` \> 0 ]; then
echo 1
fi
}
function getVideoId(){
if [ `expr index $fileNamep 'M'` \> 0 ]; then
strMIdx=`expr index $fileNamep 'M'`
strMIdx=`expr $strMIdx - 1`
videoId=`expr substr "$fileNamep" 1 $strMIdx`
echo $videoId
fi
if [ `expr index $fileNamep 'E'` \> 0 ]; then
strEIdx=`expr index $fileNamep 'E'`
strEIdx=`expr $strEIdx - 1`
videoId=`expr substr "$fileNamep" 1 $strEIdx`
echo $videoId
fi
}
function getVideoPath(){
videoId=`getVideoId`
echo `expr $videoId % 1000`/`expr $videoId % 100`/$fileNamep/
}
function getImagePath(){
videoId=`getVideoId`
imagePath=""
lenth=`expr length $videoId`
if [ $lenth -le 2 ]; then
imagePath=$videoId/shot/
echo $imagePath
else
idx=1
while [ $idx -le $lenth ]; do
if [ $idx -ge $lenth ]; then
idx=$lenth
fi
imagePath+=`expr substr "$videoId" $idx 2`/
idx=`expr $idx + 2`
done
imagePath+=shot/
echo $imagePath
fi
}
if [ "$1" == "getType" ]; then
getType
fi
if [ "$1" == "getVideoId" ]; then
getVideoId
fi
if [ "$1" == "getVideoPath" ]; then
getVideoPath
fi
if [ "$1" == "getImagePath" ]; then
getImagePath
fi
-------------------------------------------
脚本-4 cxml
path=$1
xmlfile=$path"screenshot_data.xml"
cd $path
echo > $xmlfile
if [ -f $xmlfile ]; then
echo -e "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<shot>\n<time>60</time>" > $xmlfile
imgList=(`ls *_84x46.jpg`)
len=${#imgList[@]}
for((i=0;i<$len;i=i+1))
do
echo -e "<pic time=\"10\" file=\"shot/"${imgList[i]}"\"/>" >> $xmlfile
done
echo "</shot>" >> $xmlfile
echo "operate xml success xmlfile="$xmlfile
else
echo "operate xml error xmlfile="$xmlfile
fi
--------------------------------------------
echo "email conetnt" | mail -s "email subtitle" toEmail
发送Email
--------------------------------------------
stat -c "%s" file 查看文件大小
分享到:
相关推荐
shell学习1
资源名称:Linux Shell脚本学习基础视频资源目录:【】11a00d99b60c4e2eba3440b8aa3a6bdd【】linux_shell脚本编程_01认识shell,如何编写shell脚本和执行【】linux_shell脚本编程_02vivim简单的常用操作【】linux_...
shell学习01
shell学习日志总结shell学习日志总结shell学习日志总结shell学习日志总结shell学习日志总结shell学习日志总结shell学习日志总结shell学习日志总结shell学习日志总结shell学习日志总结shell学习日志总结shell学习日志...
linux shell学习资料:Linux Shell从入门到精通、Linux Shell编程艺术、Linux Shell脚本攻略
Linux_shell脚本全面学习 Linux_shell脚本全面学习
shell学习基本命令,可以帮助初学者快速掌握较全面的shell脚本知识
shell1学习资料shell1学习资料shell1学习资料
shell学习资料 学习心得 容易懂
shell基础学习资料,对于新手学习linux shell很有用
shell学习资料(PDF) shell学习资料(PDF) shell学习资料(PDF)
此资料为shell学习资料~~~~~·喜欢就来拿吧~~~~~~~~~~~~~~~~~
Shell脚本编程(scripting)的技巧永远不会过时:它们可以让UNIX充分发挥其真实的潜能。对UNIX的用户与系统管理者而言,编写Shell脚本是必须的工作,它可以让你快速地控制与定制任何UNIX系统的强大功能。有了Shell...
Shell学习的好帮手Shell学习的好帮手Shell学习的好帮手Shell学习的好帮手Shell学习的好帮手
一些shell脚本的学习指南。一些典型的例子
shell的入门,shell程序编写,很多shell学习文档整理
Shell学习笔记Shell学习笔记Shell学习笔记Shell学习笔记Shell学习笔记Shell学习笔记
shell学习资料02