Launching a specific file when Max/MSP opens, following a crash

nicodemus's icon

I'm looking at trying to find a way to reopen a specific file if a crash occurs within Max/MSP.

I'm using Lingon to check whether or not Max has crashed, and whenever a crash occurs, it triggers Max to reopen. Which is great for reopening the program itself, the problem being I also want to have a specific patch open when Max reopens. I was wondering if there is some place that I can add something that would allow for this to happen.

Unfortunately this has come up regarding a patch that I can't turn into a standalone app at this point in time and so I'm hoping to find a way to have this happen as I've described above. Anyone have any suggestions?

mzed's icon

Which OS? You could do this with a shell script on OSX.

nicodemus's icon

I'm using OSX. How does that work with a shell script? I hadn't thought of trying it that way....

mzed's icon

I used to use a script like:

watcher () {
while [ forever ]
do
    b=0
    export TMOUT=10
    read a b c
    echo "OSC input $a $b $c"
        if [ $b -eq 1 ] ; then
        echo "Installation is running."
    else
        echo "Restarting installation."
         open -a /Applications/MaxMSP 4.6/MaxMSP.app "/Users/mzed/Desktop/Watchdog/bad_installation.mxb"
         # The next line sends an alert email
         #echo "Your installation is being restarted" | mail -s "Restart!" you@somewhere.com
    fi
done
}
dumpOSC -quiet 1750 | watcher

CNMAT's dumpOSC seems a little difficult to find, though.

I was calling it with cron, although it could be adjusted to run in a loop and sleep between checks.

mz

nicodemus's icon

Cool. Thanks so much. I'll check it out... I'm toying around with a couple of other ideas with all of this. The dumpOSC etc is giving some issues, but I may get around that. Thanks again!

mzed's icon

I would probably check if:

ps aux | grep Max.app | wc -l

was greater than 1, and ignore OSC.

mz