1 | #!/bin/sh
2 |
3 | echo " INCONVERT v1.0"
4 | echo " Description : tool to convert PRISSMA's outfile"
5 | echo " from bin to ascii and ascii to bin"
6 |
7 | #
8 | # Path definitions
9 | #
10 |
11 | LOCALDIR=`pwd`
12 | CHOICESD=$DOMHOME/TOOLS/CHOICES
13 | PERSODIR=$DOMHOME/TOOLS/INCLUDE
14 | TOOLDIR=$DOMHOME/TOOLS/INCONVERT
15 |
16 | #
17 | # Detect if all files are ready for run
18 | #
19 |
20 | ECHOICES=0
21 | DORUN=1
22 |
23 | if [ -f 'inconvert.choices' ]
24 | then
25 | ECHOICES=1
26 | fi
27 |
28 | if [ $ECHOICES -eq 1 ]
29 | then
30 | echo " Choices file found"
31 | else
32 | cp $CHOICESD/inconvert.choices .
33 | echo " -- No inconvert.choices file found, copying default file."
34 | echo " Fill the choices file and run again inconvert"
35 | DORUN=0
36 | fi
37 |
38 | if [ $DORUN -eq 1 ]
39 | then
40 | #
41 | # Detect parameters in the choices file
42 | #
43 |
44 | CONVTYPE=`head -3 inconvert.choices | tail -1 | awk '{print $1}'`
45 | CONVDEST=`head -2 inconvert.choices | tail -1 | awk -F\' '{print $2}'`
46 |
47 | #
48 | # Detect the txt directory
49 | #
50 |
51 | if [ -d $CONVDEST ]
52 | then
53 | echo "The directory $CONVDEST already exist, stop"
54 | exit
55 | else
56 | mkdir $CONVDEST
57 | fi
58 |
59 | #
60 | # Extract the archive if ascii2bin conversion
61 | #
62 |
63 | if [ $CONVTYPE -eq 2 ]
64 | then
65 | if [ -f $CONVDEST.tgz ]
66 | then
67 | echo " Extract the txt files from the $CONVDEST.tgz archive ..."
68 | tar zxf $CONVDEST.tgz > null
69 | echo " Extraction done"
70 | else
71 | echo "File $CONVDEST.tgz not found"
72 | exit
73 | fi
74 | fi
75 |
76 | #
77 | # Conversion
78 | #
79 |
80 | make -f $TOOLDIR/Makefile all
81 | $DOMHOME/HOSTS/$DOM_HOSTTYPE/inconvert_$DOM_VERSION.e_$DOM_HOSTTYPE
82 |
83 | #
84 | # Compress the txt files if bin2ascii conversion
85 | #
86 |
87 | if [ $CONVTYPE -eq 1 ]
88 | then
89 | echo " Compressing the txt files ..."
90 | tar -zcf $CONVDEST.tgz $CONVDEST
91 | echo " Compression done to the $CONVDEST.tgz file"
92 | fi
93 |
94 | rm -rf $CONVDEST
95 |
96 | fi