bat脚本调用Android中bash脚本,关闭bat后如何保持bash继续运行
2016-04-15 17:05
926 查看
例子:
(
目的是使bat脚本关闭后,startFloatWindow.sh继续运行。
这里使用a.sh脚本过渡,来后台启动startFloatWindow.sh。
关键点有两个:
1、a.sh中的&,表示后台启动新进程;
2、bat脚本中执行a.sh时,使用adb shell < temp.txt的方式,否则a.sh无法调用到startFloatWindow.sh
)
1、bat脚本内容如下:
adb push startFloatWindow.sh /data
adb push a.sh /data
adb shell "chmod 777 /data/startFloatWindow.sh"
adb shell "chmod 777 /data/a.sh"
echo cd /data >temp.txt
echo sh ./a.sh>>temp.txt
adb shell<temp.txt
2、a.sh脚本内容如下:
#!/system/bin/sh
echo "start run monitor 1..."
sh /data/startFloatWindow.sh&
3、startFloatWindow.sh脚本内容如下:
while true;
do
am startservice com.example.a/com.huawei.zhenshimoxing.FloatWindowService
sleep 1
echo "#"
done
(
目的是使bat脚本关闭后,startFloatWindow.sh继续运行。
这里使用a.sh脚本过渡,来后台启动startFloatWindow.sh。
关键点有两个:
1、a.sh中的&,表示后台启动新进程;
2、bat脚本中执行a.sh时,使用adb shell < temp.txt的方式,否则a.sh无法调用到startFloatWindow.sh
)
1、bat脚本内容如下:
adb push startFloatWindow.sh /data
adb push a.sh /data
adb shell "chmod 777 /data/startFloatWindow.sh"
adb shell "chmod 777 /data/a.sh"
echo cd /data >temp.txt
echo sh ./a.sh>>temp.txt
adb shell<temp.txt
2、a.sh脚本内容如下:
#!/system/bin/sh
echo "start run monitor 1..."
sh /data/startFloatWindow.sh&
3、startFloatWindow.sh脚本内容如下:
while true;
do
am startservice com.example.a/com.huawei.zhenshimoxing.FloatWindowService
sleep 1
echo "#"
done
相关文章推荐
- shell条件-循环-分支-函数
- shell mysql命令 传参数
- 学习shell 指令 压缩文件
- 常用Shell命令
- shell脚本中判断文件是否存在
- linux中shell 特殊变量$0 $n $* $@ $! $?的详解
- 同一Linux主机上共用shell寻求远程协助
- 解决bash: mysql: command not found 的方法
- shell 重定向
- 用c写cgi程序,不能在cgi程序中执行shell命令
- (转载)SQL Server 2005 如何启用xp_cmdshell组件
- Linux-shell编程简单程序
- linux 批量scp自动上传文件的shell脚本
- Ubuntu下shell脚本运行异常:bash和dash的区别
- bash计算性能
- 王高利:Linux_shell三剑客之sed命令使用详解
- shell编程基础------函数
- linux下提示bash:command not found_带目录下命令列表介绍
- Xshell用ssh连接ubuntu掉线解决方法
- 关注微软的“bash on windows”