-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.sh
155 lines (148 loc) · 4.53 KB
/
menu.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/bin/bash
# Bash Menu Script Example
PS3='Choice: '
options=("HDFS Menu" "MapReduce Tutorial" "Quit")
hdfsoptions=("Get File Status" "Make Directory" "Create File" "Read File" "Delete File" "Copy File" "Quit")
mapreoptions=("Average" "Max-Min" "Range" "Spread" "Sum" "Quit")
JAR="mapreduce/mapr.jar"
select opt in "${options[@]}"
do
case $opt in
"HDFS Menu")
echo "you chose choice 1"
select hdfsopt in "${hdfsoptions[@]}"
do
case $hdfsopt in
"Get File Status")
printf "File name : "
read -r filename
hadoop jar $JAR MapReduceHdfs getfilestatus $filename
;;
"Make Directory")
printf "Directory Name : "
read -r dirname
hadoop jar $JAR MapReduceHdfs mkdir $dirname
;;
"Create File")
printf "File name : "
read -r filename
hadoop jar $JAR MapReduceHdfs createfile $filename
;;
"Read File")
printf "File name : "
read -r filename
hadoop jar $JAR MapReduceHdfs readfile $filename
;;
"Delete File")
printf "File name : "
read -r filename
hadoop jar $JAR MapReduceHdfs deletefile $filename
;;
"Copy File")
printf "Source : "
read -r filesource
printf "Destination : "
read -r filedestination
hadoop jar $JAR MapReduceHdfs copyfile $filesource $filedestination
;;
"Quit")
echo "1) HDFS Menu"
echo "2) MapReduce Tutorial"
echo "3) Quit"
break
;;
*) echo "invalid option $REPLY";;
esac
echo "-------------------"
echo "1) Get File Status"
echo "2) Make Directory"
echo "3) Create File"
echo "4) Read File"
echo "5) Delete File"
echo "6) Copy File"
echo "7) Back Main Menu"
echo "------------------"
done
;;
"MapReduce Tutorial")
echo "you chose choice 2"
select mapreopt in "${mapreoptions[@]}"
do
case $mapreopt in
"Average")
printf "input : "
read -r input
printf "output : "
read -r output
echo ""
hdfs dfs -rm -R $output
hadoop jar $JAR MapReduceAverage $input $output
hdfs dfs -cat $output/part-r-00000
;;
"Max-Min")
printf "input : "
read -r input
printf "output : "
read -r output
echo ""
hdfs dfs -rm -R $output
hadoop jar $JAR MapReduceMaxmin $input $output
hdfs dfs -cat $output/part-r-00000
;;
"Range")
printf "input : "
read -r input
printf "output : "
read -r output
echo ""
hdfs dfs -rm -R $output
hadoop jar $JAR MapReduceRange $input $output
hdfs dfs -cat $output/part-r-00000
;;
"Spread")
printf "input : "
read -r input
printf "output : "
read -r output
echo ""
hdfs dfs -rm -R $output
hadoop jar $JAR MapReduceSpread $input $output
hdfs dfs -cat $output/part-r-00000
;;
"Sum")
printf "input : "
read -r input
printf "output : "
read -r output
echo ""
hdfs dfs -rm -R $output
hadoop jar $JAR MapReduceSum $input $output
hdfs dfs -cat $output/part-r-00000
;;
"Quit")
echo "---------------------"
echo "1) HDFS Menu"
echo "2) MapReduce Tutorial"
echo "3) Quit"
echo "---------------------"
break
;;
*) echo "invalid option $REPLY";;
esac
echo ""
echo "-------------------"
echo "1) Average"
echo "2) Max-Min"
echo "3) Range"
echo "4) Spread"
echo "5) Sum"
echo "6) Back Main Menu"
echo "------------------"
done
;;
"Quit")
break
;;
*) echo "invalid option $REPLY";;
esac
done