Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- declare -A array
- declare -a arejneki
- declare -a arejzimeni
- declare -A zakillat
- uporabnik=$(whoami)
- touch temp.txt
- chmod +x temp.txt
- touch temp2.txt
- chmod +x temp2.txt
- while read vrstica < $1
- do
- celota="$vrstica"
- kaj="$(cut -d":" -f1 <<< "$celota")"
- echo "${array[imeprocesa]}"
- if [[ "$kaj" == "run" ]]; then
- check="$(cut -d":" -f2 <<< "$celota")"
- spanec="$(cut -d":" -f3 <<< "$celota")"
- imeprocesa="$(cut -d":" -f4 <<< "$celota")"
- kaj="$(cut -d":" -f1 <<< "$celota")"
- if [[ $celota = *" "* ]]; then
- imeproces2="$(cut -d" " -f1 <<< "$imeprocesa")"
- celota2="$imeproces2:$celota"
- array[imeprocesa]="$celota2"
- else
- celota="$imeprocesa:$celota"
- array[imeprocesa]="$celota"
- fi
- zapreverjatime="$(cut -d":" -f1 <<< "${array[imeprocesa]}")"
- echo "${array[imeprocesa]}"
- stevilo=$( pgrep -xfc -g "$$" "$zapreverjatime" )
- if ! [ -x "$(command -v ${imeprocesa})" ] || [ "$imeprocesa" == "" ]; then
- if [ "$imeprocesa" == "" ]; then
- ena="./$2"
- else
- ena="$(cut -d" " -f1 <<< "$imeprocesa")"
- fi
- echo "Command not runnable: "$ena >&2
- else
- while true; do
- stevilo=$( pgrep -xfc -g "$$" "$zapreverjatime" )
- if [[ $stevilo -lt $check ]]; then
- $imeprocesa &
- stevilka=$!
- zakillat[imeprocesa]+="$stevilka "
- echo "$imeprocesa " > temp2.txt
- sleep $spanec
- echo "${zakillat[imeprocesa]}" > temp.txt
- fi
- done &
- fi
- elif [[ "$kaj" == "exit" ]]; then
- kill -- -$$
- exit 100;
- elif [[ "$kaj" == "stop" ]]; then
- stevilo="$(cut -d":" -f3 <<< "$celota")"
- elif [[ "$kaj" == "log" ]]; then
- imezapot=""
- noustring=""
- koncnoime=""
- kdajjepraznkdajne=""
- while IFS='' read -r line || [[ "$line" ]]; do
- imezapot="$( cut -d" " -f1 <<< "$line")"
- if [[ $line = *" "* ]]; then
- imezapot="$( cut -d" " -f1 <<< "$imezapot")"
- kdajjepraznkdajne="$( cut -d" " -f2 <<< "$line")"
- else
- neki=true
- fi
- done < temp2.txt
- echo "$( which "$imezapot" ) $kdajjepraznkdajne"
- echo "$( which "$imezapot" ) $kdajjepraznkdajne">>active.log
- while IFS='' read -r line || [[ "$line" ]]; do
- echo "$line ">>active.log
- done < temp.txt
- elif [[ "$kaj" == "log last" ]]; then
- imezapot=""
- noustring=""
- koncnoime=""
- kdajjepraznkdajne=""
- while IFS='' read -r line || [[ "$line" ]]; do
- imezapot="$( cut -d" " -f1 <<< "$line")"
- if [[ $line = *" "* ]]; then
- imezapot="$( cut -d" " -f1 <<< "$imezapot")"
- kdajjepraznkdajne="$( cut -d" " -f2 <<< "$line")"
- else
- neki=true
- fi
- done < temp2.txt
- echo "$( which "$imezapot" ) $kdajjepraznkdajne"
- echo "$( which "$imezapot" ) $kdajjepraznkdajne">>active.log
- while IFS='' read -r line || [[ "$line" ]]; do
- echo "$line ">>active.log
- done < temp.txt
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement