-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo
48 lines (26 loc) · 1.05 KB
/
demo
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
#! /usr/bin/env bash
# Print an error message and exit.
panic()
{
echo "ERROR: $@"
exit 1
}
### create input file that will be pipelined to be compressed ####
echo "####the following input will be writte to a file called input.txt for compression###:"
echo "This is a file created by the bash script with example input for the Huffmancoder program"
echo "This is a file created by the bash script with example input for the Huffmancoder program\n" >input.txt
# Get the directory in which the currently running script is located.
cmd_dir=$(dirname "$0") || panic "cannot determine command directory"
Huffmancoder="$cmd_dir/Huffmancoder"
$Huffmancoder -c <input.txt >compressed_demo.txt|| panic "encoding program failed"
$Huffmancoder -d <compressed_demo.txt >decompressed_demo.txt || panic "decoding program failed"
echo "###SUMMARY####"
echo "##ORIGINAL INPUT##:"
cat input.txt
echo "##Compressed data##"
cat compressed_demo.txt
echo "DECOMPRESSED OUTPUT:"
cat decompressed_demo.txt
rm input.txt
rm compressed_demo.txt
rm decompressed_demo.txt