Wait (the end of N process in ksh and after run another process) dont work correctly

馋奶兔 提交于 2019-12-14 04:27:17

问题


my script is:

#!/bin/ksh

WORKFLOW1=wf_m_LOAD_ODS_DMT_FATTO_E_BSN_LETTURE_F
WORKFLOW2=wf_m_LOAD_ODS_DMT_FATTO_E_ANAGRAFICA_POD_F
WORKFLOW3=wf_m_LOAD_ODS_DMT_FATTI_E_QF_F
pmcmd startworkflow -sv $SERVER -d $DOMINIO -u $USER -p $PASSWD -f $DIRECTORY_SEC_LEV_ELE $WORKFLOW1 & pmcmd startworkflow -sv $SERVER -d $DOMINIO -u $USER -p $PASSWD -f $DIRECTORY_SEC_LEV_ELE $WORKFLOW2 & pmcmd startworkflow -sv $SERVER -d $DOMINIO -u $USER -p $PASSWD -f $DIRECTORY_SEC_LEV_ELE $WORKFLOW3 &;
wait;

echo "Lancio creazione indici T_DMT_SEE_FT_BSN_LETTURE">>log_DMT_R1.log
sqlplus $USERDBDMT/$PASSDBDMT@$SIDDB @create_index_T_DMT_SEE_FT_BSN_LETTURE.sql &

I have error:

./Start_lancio_unico_ELE_DMT_INFASAMENTO_FT.sh: line 27: syntax error near unexpected token `;'
./Start_lancio_unico_ELE_DMT_INFASAMENTO_FT.sh: line 27: `pmcmd startworkflow -sv $SERVER -d $DOMINIO -u $USER -p $PASSWD -f $DIRECTORY_SEC_LEV_ELE $WORKFLOW1 &;'

why ; is not correct?

i want run 3 process in background and after they are finished run a 3th process.

thanks to all


回答1:


It appears that's a bash error, not a ksh error. How are you invoking the script?

$ cat script.sh
#!/usr/bin/ksh
sleep 5 &;
wait; 
echo done
$ ksh script.sh
done
$ bash script.sh
script.sh: line 2: syntax error near unexpected token `;'
script.sh: line 2: `sleep 5 &;'

In bash, both & and ; are command terminators, and it's apparently an error to use both. Ref: http://www.gnu.org/software/bash/manual/bashref.html#Lists

A list is a sequence of one or more pipelines separated by one of the operators ‘;’, ‘&’, ‘&&’, or ‘||’, and optionally terminated by one of ‘;’, ‘&’, or a newline.

(emphasis mine)



来源:https://stackoverflow.com/questions/23113267/wait-the-end-of-n-process-in-ksh-and-after-run-another-process-dont-work-corre

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!