Hi all,
that's my personal "war story" and probably a beginning of a never ending love story.
It is roughly 8 weeks ago, I've got a training for a new ERP system. In front of the training my boss mentioned it based on a unix. Great, I have been always interested in but I don't know why I haven't invest time in it. Anyway, the training was great and it has awaken my passion.
Now, I try to invest every second to get more knowledge and especially the shell scripting and programming brings my heart to beat. That's the love story
Back to my "war story". I am responsible for testing the interface between an ERP and MES System. The problem it takes ages to get test data in order to verify it. Supplier pushed out deliveries for months. Honestly, supplier has a lot of more important stuff to do in order to get the ERP System running but I HAVE TO TEST THE INTERFACE. Hence, I've decided to write a shell script in order to simulate the interface communication and begin testing. My intention is to post the result and share result in this forum. (probably other rookies like me will get benefit)
ERP-MES Interface:
Output: UTF-8 file (without Byte Order Mark)
Content of UTF File: string (1000 digits) & CR & LF
- Creation of UTF FIle via BASH Script
Content of BASH Script:
- function to modify variabels (numeric, decimal, character)
- merge all variables to one string
- create UTF File with string
- Question regarding the result of variable output (quoted/unquoted) --> ERP - MES Interface - several function
- Question regarding formatting decimal value --> http://www.unix.com/shell-programming-scripting/218251-formatting-decimal-value.html\#post302780189
#!/bin/bash
fct_var_mod() {
case "$1" in
"C") if [ ${#2} -eq "$3" ]
then value="$2"
else value="$(printf "%-$3.$3s" "$2")"
fi;;
"N") value="$(printf "%0$3d" "$2" )"
value="$(printf "%.$3s" "$value" )";;
"D") value="$(printf "%-$3.$3s" "$2" )"
value="$(printf "%+0$3.$4f" "$value")";;
esac
}
order_no_t=C; order_no=ORDER005-010010; order_no_l=40
fct_var_mod $order_no_t $order_no $order_no_l
order_no="$value"; echo "$order_no"
proc_no_T=N; proc_no=1283; proc_no_l=8
fct_var_mod $proc_no_T $proc_no $proc_no_l
proc_no="$value"; echo "$proc_no"
qty_t=D; qty_val=-12345678.123; qty_l=13; qty_p=3
fct_var_mod $qty_t $qty_val $qty_l $qty_p
qty_val="$value"; echo "$qty_val"
Diary:
2nd of March 2013 - Let's go
3rd of March 2013 - got great comments from Don Cragun
4th of March 2013 - added comments and mods from Don Cragun to basic post (#1)
14th of March 2013 - added formatting numeric and decimal values