1 |
#! /bin/sh |
2 |
|
3 |
#================================================================ |
4 |
# extfxmsotohtml |
5 |
# Convert MS-Word, MS-Excel, or MS-PowerPoint into HTML |
6 |
#================================================================ |
7 |
|
8 |
|
9 |
# set variables |
10 |
PATH="$PATH:/usr/local/bin:$HOME/bin:." ; export PATH |
11 |
progname="estfxmsotohtml" |
12 |
|
13 |
|
14 |
# check arguments |
15 |
if [ $# -lt 1 ] |
16 |
then |
17 |
printf '%s: usage: %s infile [outfile]\n' "$progname" "$progname" 1>&2 |
18 |
exit 1 |
19 |
fi |
20 |
infile="$1" |
21 |
outfile="$2" |
22 |
if [ -n "$ESTORIGFILE" ] && [ -f "$ESTORIGFILE" ] |
23 |
then |
24 |
infile="$ESTORIGFILE" |
25 |
fi |
26 |
|
27 |
|
28 |
# check the input |
29 |
if [ "!" -f "$infile" ] |
30 |
then |
31 |
printf '%s: %s: no such file\n' "$progname" "$infile" 1>&2 |
32 |
exit 1 |
33 |
fi |
34 |
|
35 |
|
36 |
# initialize the output file |
37 |
if [ -n "$outfile" ] |
38 |
then |
39 |
rm -f "$outfile" |
40 |
fi |
41 |
|
42 |
|
43 |
# function to output |
44 |
output(){ |
45 |
if [ -n "$outfile" ] |
46 |
then |
47 |
cat >> "$outfile" |
48 |
else |
49 |
cat |
50 |
fi |
51 |
} |
52 |
|
53 |
|
54 |
# output the result |
55 |
case "$infile" in |
56 |
*.doc) |
57 |
wvWare --charset=UTF-8 --nographics "$infile" 2> "/dev/null" | output |
58 |
;; |
59 |
*.xls) |
60 |
xlhtml "$infile" 2> "/dev/null" | output |
61 |
;; |
62 |
*.ppt) |
63 |
ppthtml "$infile" 2> "/dev/null" | output |
64 |
;; |
65 |
*) |
66 |
printf '<div>!!! UNKNOWN FORMAT !!!</div>\n' | output |
67 |
;; |
68 |
esac |
69 |
|
70 |
|
71 |
# exit normally |
72 |
exit 0 |
73 |
|
74 |
|
75 |
|
76 |
# END OF FILE |