linux - Can't get BASH script to wait for PID -


i building script make life easier when setting servers.

i having issue line:

# code mv/cp/chown files (working intended) sudo su $install_user -c \     "sh $software_dir/soa/disk1/runinstaller \     -silent -response $reponse_loc/response_wls.rsp \     -invptrloc  $ora_loc/orainsta.loc \     -jreloc /usr/java/latest" >&3 soa_pid = pgrep java wait $soa_pid # code below requires completed before execution.  

i trying script wait process complete before continues on.

the script executes, instead of waiting, continues on, , execution of installer runs after script finishes. have other installer pieces need part installed before start own process, hence wait.

i've tried using $! etc, since piece executing separate user, don't know if work.

thanks assistance.

the command soa_pid = pgrep java should result in error.

try capture pid this:

soa_pid=$( pgrep java ) || exit 

the || exit forces exit if pgrep not return value, preventing nonsense happening further on. alternative rely on wait return immediately, it's better explicit.

when using in function you'd use || return instead, depending on circumstances.


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -