#!/bin/sh #Copyright (C) Texas Instruments Incorporated - http://www.ti.com/
#
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the
# distribution.
#
# Neither the name of Texas Instruments Incorporated nor the names of
# its contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. mkdir -p tmp # 创建tmp目录
mkdir -p lock # 创建lock目录 i= for item in "$@" # 迭代传入的参数
do if [ $i -eq ]
then filename=$item # 获取文件名
fi if [ $i -eq ]
then outputfilename=$item # 获取输出文件名
fi if [ $i -gt ]
then
touch "lock/"$item # 创建lock文件,这个好象是暗个随机生成的数字字符串 fi
i=`expr $i + ` # i++ done echo "Filename:"$filename
echo "Output:"$outputfilename
# . 执行程序,程序会卡在这里?以下是run_script.php运行程序:
# $script_link = $found_app["Exec"];
# # strval(): 用于获取变量对应的字符串值
# # rand(): 返回随机整数
# $random_string = strval(rand());
# $random_string .= strval(rand());
# # addslashes(): 在指定的预定义字符前添加反斜杠
# $script_command = "./execute_command.sh \"".addslashes($script_link). "\" ".$random_string.".txt ".$lock_list;
# # 获取系统执行结果最后一行
# # system()第二个参数:如果提供的return_var参数,则外部命令执行后的
# # 返回状态将会被设置到此变量中
# $last_line = system($script_command." > /dev/null 2>/dev/null & ", $retval);
# . 对于Qt应用程序,个人觉得这里还是堵塞
eval $filename > "tmp/"$outputfilename >& #Using a more unique string to detect if the script is completed
# 这行文字重定向到tmp下的输出文件尾
echo "_?!!MATRIX_SCRIPT_COMPLETED!!?_" >> "tmp/"$outputfilename # 清一下屏,没找到这条命令
refresh_screen & i=
for item in "$@"
do if [ $i -gt ]
then
rm -f "lock/"$item # 删除lock下的文件 fi
i=`expr $i + ` # i++ done sleep
rm "tmp/"$outputfilename # 删除tmp下的文件