2018/07/23

bash script to kill another script by pid file

the idea is to get the pid from a running script and save it to a file, so we can retrieve the id and kill the process. Also it should kill child processes

to create the file, during the script we must do (replace /home/mantener/var/run with another dir of your liking):

minombre=$(basename $0)
pidfile=/home/mantener/var/run/$minombre.pid
echo $$ >$pidfile

 
 and the script to make use of the pid file could be:

#!/bin/bash
pidfile=/home/mantener/var/run/$1.pid

if [ ! -f $pidfile ] ; then
   echo missing $pidfile !
   logger $0 missing $pidfile !
   exit -1
fi

cualpid=$(cat $pidfile)

# get child processes
resto=$(ps --ppid $cualpid -o pid --no-headers)

echo killing $1
kill -9 $cualpid

while IFS= read -r line ; do
    echo killing $line
    kill -9 $line
done <<< "$resto"

rm $pidfile

2018/07/19

script to kill a specific process by name

This one was made specifically for VLC since the stupid program sometimes hangs and there is no way to close it by normal means (Quit command, etc)

#!/bin/bash
$(echo -n kill -9 ; ps -A |grep vlc |grep -o "^ [0-9]*")
what it does is to create a command line on the fly by extracting vlc process id and then execute it.

2018/07/09

Autofill forms for Chromium and Firefox

Why/when do you need it:
  • because you use the same web page from time to time and you need to fill a form with the same data (ie: user/pass)
  • related to the above, once configured with a hotkey, logging in a site in is just a second
  • security is not an issue
  • a natural complement to Lazarus addon for Firefox
  • if you are like me, who sticks to Firefox 40-48 because many addons does not work on newer versions, you might want to use Chromium for specific web pages
Firefox version:

https://firefox.add0n.com/autofill-forms.html

for Chromium

https://add0n.com/autofillforms-e10s.html

compared with the Addon for Firefox (version 1.1.8), Chromium addon is horrible beyond belief. I feel like some software developers are treating users as if they were morons incapable of thinking for themselves so they try to spoon-feed them with fancy dialogs and buttons limiting what they can and cannot do. Proof of that is the first item on the Features list: "Easy configuration with a simple interface"