我是 Shell Script Linux 的新手。
我正在使用 Android 进行自动化测试,所以我想运行一些 shell 脚本,如下所示:
- 开始通过adb(cmd1.sh)录屏
- 做场景测试然后停止/保存记录的文件(cmd2.sh)
不幸的是,当我运行 cmd1.sh 时,我必须等待 3 分钟才能运行 cmd2.sh。
这意味着我无法录制视频:sad:
这是我的运行命令内容:
run.sh文件内容:
./cmd1.sh $
./cmd2.sh
cmd1.sh文件内容:
adb shell screenrecord /sdcard/file.mp4
cmd2.sh文件内容:
calabash-android run app.apk
最后,我打开终端然后运行命令:
./run.sh
当然,视频是不能保存的,因为在cmd1.sh执行完之后,cmd2.sh正在运行!!!
在这一点上有人可以帮助我吗?
太感谢了 !
@Jrican 已更新
这是我可以播放视频录制的手动步骤。
1. 打开终端 A
2.运行命令1(开始录屏脚本)
3.打开其他终端B然后运行命令2
4. 命令 2 完成后,返回终端 A 然后按 Ctrl C。
5.确认/sdcard/file.mp4中的视频可以正常播放
我正在使用 MAC OSX Yosemite 10.10.5
最佳答案
简单的解决方案: run.sh文件内容:
./cmd1.sh & # run this command in the background
./cmd2.sh # run this command to completion
kill -SIGINT %1 # send the interrupt signal to the first command (ctrl+c)
稍微更正确的解决方案: run.sh文件内容:
./cmd1.sh & # run this command in the background
recPID=$! # save the PID for this process for later
./cmd2.sh # run this command to completion
kill -SIGINT $recPID # send the interrupt signal to the first command (ctrl+c)
关于linux - 运行命令而不让我等待,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32982510/