JSP
JSP

Reputation: 587

Uninstall softwares one after another using shell script

I want to uninstall two software's based on completion of first uninstaller. Mean to say , I don't want to start second uninstaller until we complete the first uninstaller.

Can anyone please suggest me how can I achieve this scenario.

This is what I followed now.

uninstall.sh:

if [ $exitval -eq 0 ] then 
    ./uninstall1.sh
else
    echo uninstall1.sh else loop
fi

result=$?

if [ $result -eq 0 ]
    ./uninstall2.sh
else
    echo uninstall2.sh else loop
fi

Here the issue is , uninstaller1 will launch one UI. Before completion of uninstaller1, uninstaller2 UI will get launch. This is what I don't want.

Want to launch uninstall2 when uninstall1 gets finish.

Update : After goggling came to know that we can achieve this by using wait command. But, still struggling with the same issue .

Thanks In Advance.

Upvotes: 0

Views: 76

Answers (1)

konsolebox
konsolebox

Reputation: 75558

Anyhow I'd just post my pending suggestion:

SomeLauncher1.sh

PID=$!  ## Not really the way to do it but this is one way how.

while kill -s 0 "$PID"; do  ## If true, process is still running.
    sleep 1s  ## Keep waiting.
done

SomeLauncher2.sh

... ## Perhaps do the same thing again.

Upvotes: 1

Related Questions