/
exec_command_list_prompt.sh
56 lines (44 loc) · 1.09 KB
/
exec_command_list_prompt.sh
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
#!/bin/sh
sdsf_rexx=$HOME/REXX/sdsf.rex
if [ $# -ne 1 ]
then
echo "Usage:"
echo " # " $0 "<SDSF_command_list_file>"
exit 1
fi
FILENAME=$1
if [ ! -e ${FILENAME} ]
then
echo ${FILENAME} ": file not found"
exit 1
fi
idx=0
while read my_command[idx]
do
echo $idx : ${my_command[$idx]}
idx=$(( idx+1 ))
done < ${FILENAME}
echo number of commands: ${idx}
i=0
while [[ i -lt idx ]]
do
echo ""
echo ""
echo "************************************************************************************"
echo "Next Command ("$((i+1))"/"${idx}"): " ${my_command[${i}]}
echo "Execute this command: [enter] / Skip this command : s / Finish this script: f "
echo "************************************************************************************"
read inputChar?"Input>"
if [[ ${inputChar} = "s" || ${inputChar} = "S" ]]
then
echo "--- Skip this command ---"
elif [[ ${inputChar} = "f" || ${inputChar} = "F" ]]
then
echo "--- Finish this script ---"
exit 1
else
echo "--- Execute this command ---"
${sdsf_rexx} ${my_command[${i}]}
fi
i=$(( i+1 ))
done