-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtry1
More file actions
59 lines (48 loc) · 1.02 KB
/
try1
File metadata and controls
59 lines (48 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
command=""
interval=""
number=""
########################################
####### parsing args first ###########
########################################
while [ $# -gt 0 ];do
arg1=$1
case $arg1 in
-i)
interval=$2
shift 2
;;
-n)
number=$2
shift 2
;;
*)
command="$command $1"
shift
;;
esac
done
###################################################
######## checking if command is installed #########
###################################################
which $(echo $command | awk '{print $1}') > /dev/null 2>&1
if [ $? -eq 0 ];then
$command 2> /dev/null
if [ $? -eq 0 ];then
exit 0
else
for (( i=1; i<$number; i++ ))
do
sleep $interval
$command 2> /dev/null
if [ $? -eq 0 ];then
exit 0
fi
done
echo "$command not successfully run !!!" >&2
exit 1
fi
else
echo "command $(echo $command | awk '{print $1}') is Not installed" >&2;
exit 1
fi