script for program update and restart
I developed an application in Matlab and I compiled it in Linux.
My application can check for updates online and download them.
The aim is to have the updates installed and to restart the application (automatically).
The installation consists basically just in unzipping the code and replace the current one with the new one.
I thought to have Matlab write a bash script and then launch it to install the code and then restart. However I cannot understand why it cannot restart.
The bash script I wrote makes the following operations (files are already unzipped from within Matlab):
- it kills the current application (so that it can be replaced by the new one)
- it moves the unzipped files from a temporary directory to the target directory replacing the old files
- it removes the temporary directory
- it calls the new executable (in fact, it's calling a bash script which launches the Matlab compiled application)
The bash script I wrote is correctly launched. In fact, it kills the current application, it replaces the files and it removes the temporary directory. However, the new executable is not executed.
I tried using exec, or opening a new xterm with the new application, or using disown or nohup, no luck in any case.
If I launch the script manually, it correctly calls the new executable. But if it is launched from within the old application, it does not work (or better: as I said only some operations are executed).
Here the script:
#!/bin/sh
kill -9 $(pidof main)
mv -f /periz/matlab/compiled-linux/archive/tmp/* /periz/matlab/compiled-linux/
rmdir /periz/matlab/compiled-linux/archive/tmp
/periz/matlab/compiled-linux/run_main.sh /usr/local/MATLAB/MATLAB_Compiler_Runtime/v83
What am I missing?
Many thanks!!!
Last edited by periz; 04-27-2015 at 10:11 AM.
Reason: I'm adding the code
|