0
Hello, I am trying to automate a task and am encountering problems with PID. My code:
for i in 5 10
do
echo "omnetpp.ini Generated! Running."
../../bin/Castalia -c General
PIDCAST=$(ps aux |grep CastaliaBin |tr -s " " | cut -d" " -f2)
wait $PIDCAST
cp Castalia-Trace.txt Castalia-Trace_$i.txt
rm Castalia-Trace.txt
rm omnetpp.ini
done
this call .. /.. /bin/Castalia runs a simulator. I would like to make the script wait for the end of running this simulator (I used the Wait command), to copy the log file (Catalia-Trace.txt), delete it after copying and run the for again.
The problem is that this way is returning the error:
omnetpp.ini Generated! Running.
./executa.sh: linha 88: wait: o pid 2573 não é um processo filho deste shell
cp: não foi possível obter estado de 'Castalia-Trace.txt': Arquivo ou diretório inexistente
rm: não foi possível remover 'Castalia-Trace.txt': Arquivo ou diretório inexistente
Someone could help me with this lawsuit situation?
you need to get more details of the application Castalia...probably the binary Castaliabin is running in a subshell, or in a Detached job (daemon), so you really can’t do Wait PID because Castaliabin is not the child of the initial shell
– zentrunix
I appreciate the help, but I managed to make a Sleep.
– ARSaraiva