简体   繁体   English

单个bash脚本中的多个顺序执行任务

[英]Multiple sequential exec tasks in a single bash script

I'm trying to run the following two tasks in a bash script being triggered from a php script. 我正在尝试从php脚本触发的bash脚本中运行以下两个任务。 Both of these are executing correctly when I comment out the other so it's obviously the way I've incorrectly laid out the complete job. 当我注释掉另一个时,这两个命令都可以正确执行,这显然是我错误地安排了完整工作的方式。

They should be run sequentially, not in parallel, so the first exec needs to finish before the second one starts... 它们应该按顺序而不是并行运行,因此第一个执行程序需要在第二个执行程序开始之前完成...

I should also note that the variables are being passed through from the php script that is triggering it (in case it's relevant). 我还应注意,变量是通过触发它的php脚本传递的(如果它是相关的)。

#!/bin/bash

Udata1=$1
Udata2=$2

#Encode incoming audio file to 128k MP3 using avconv
exec avconv - i /var/www/html/tracks/$Udata1/$Udata2 -ab 128k /var/www/html/tracks/$Udata1/serve/$Udata2.128k.mp3;

#Encode 128k MP3 generated above to WAV using avconv
exec avconv -i /var/www/html/tracks/$Udata1/serve/$Udata2.128k.mp3 /varwww/html/dump/$Udata2.wav

exit;

I guess what I'm utlimately asking is how to run multiple exec's in the same .sh script? 我想我要问的是如何在同一个.sh脚本中运行多个exec?

exec replaces the currently running process with the spawned process. exec用生成的进程替换当前正在运行的进程。 It never returns. 它永远不会回来。 You can't exec two things like that. 你不能exec两件事。

That said you don't need to. 那就是说你不需要。 Just remove exec from those two lines and it should work fine. 只需从这两行中删除exec ,它就可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM