Alert: "Firefox is Running..." |Solution|

I want to write a bash script to fix the firefox crashing with my friend (~necdet). This script works incomplete because of some errors (~null exception etc..). This is;

###############################################
#!/bin/sh

export men=$(pidof firefox-bin)
cd ~
for x in $(find .mozilla | grep lock); do
rm $x
done
echo "Step(1/2).."

#if[ "$men" -eq 0 ] then
if [ $men -lt 10000000 ];
then
kill -9 $(pidof firefox-bin)
echo "Step(2/2).."
echo "OK..!"
exit 1

else
echo "Firefox Already Running"
exit 1
fi

###############################################

with helping CanBurak, i fix them...

Finally,

###############################################

# # # # # # # # # # # # # # # # #
# Hakan Ilgar #
# robmind@gmail.com #
# # # # # # # # # # # # # # # # #

#!/bin/sh

if [ "$(pidof firefox-bin)" == "" ];
then
echo "Firefox isnot Running!"
else

#if $? == 0
#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
#xxxxx Other, File finding alternatives by CanBurak xxxxxxxx
#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# for x in $(find ~/.mozilla | grep lock); do
# rm $x
# done
#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# find ~/.mozilla | grep lock | while read line; do
# rm $line
# done
#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# find ~/.mozilla | grep lock | xargs rm
#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# find -name lock -exec rm {} \;
#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
find -name lock | xargs rm

echo "Step(1/2).."
echo "-----------"
kill -9 $(pidof firefox-bin)
echo "Step(2/2).."
echo "-----------"
echo "OK..!"
exit 1
fi


###############################################

No comments: