Operating System - HP-UX
1833776 Members
2128 Online
110063 Solutions
New Discussion

filename changes before previous command finishes- BL870c

 

filename changes before previous command finishes- BL870c

We have a Bl870c server running HP-UX 11iv2, a Oracle Database server. The attached shell script pulls a file in from a sftp server and processes the file.

The mv command to rename the file seems to execute before the previous awrun command can finish.

My assumption is that the awrun command is running on a different CPU than the mv command.

Is there a way to make shell script wait for the previous command to finish before another?

We put a sleep 10 command and it works fine.

Should we put a if [ $? = 0 ] then mv
2 REPLIES 2
James R. Ferguson
Acclaimed Contributor

Re: filename changes before previous command finishes- BL870c

Hi:

Normally, commands in a script are simply executed synchronously so that nothing begins until the previous command (process) has completed (successfully or not).

You don't say what the 'awrun' process is doing or how it is coded. If it does something like a fork() to perform work, your shell script resume execution before the work is completed.

If the simple sleep() works, you could continue to use that. If the 'awrun' returns a useful return code, then, yes, I would test it and do the 'mv' accordingly, too.

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: filename changes before previous command finishes- BL870c

>Should we put a if [ $? = 0 ]

The proper syntax (integer compare) is: [ $? -eq 0 ]