简体   繁体   中英

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. 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).

#!/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?

exec replaces the currently running process with the spawned process. It never returns. You can't exec two things like that.

That said you don't need to. Just remove exec from those two lines and it should work fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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