/.emacs.d/el-get/nxhtml/tests/in/question49234.sh

https://bitbucket.org/shuangxinyu/emacspack · Shell · 41 lines · 32 code · 8 blank · 1 comment · 1 complexity · ffa0955bcfe28b5fa79962f85adfa50a MD5 · raw file

  1. #!/bin/ksh
  2. . /bin/shared/.mkt.cfg
  3. STORE_TMP=/tmp/stores.txt
  4. cd /spool/xml
  5. rm -f $STORE_TMP
  6. bteq << EOF
  7. .SESSIONS 1
  8. .LOGON $UserId,$Password;
  9. .EXPORT DATA FILE "$STORE_TMP"
  10. select division_id,store_id,
  11. trim(store)||' '||trim(store_addr_line2_txt)||', '||
  12. trim(store_city)
  13. from stores
  14. where status_id='A'
  15. and division_id in (517,1920,2445)
  16. order by division_id,store_city,store_id;
  17. .EXIT 0
  18. EOF
  19. perl <<EOF > $1
  20. print qq(<?xml version="1.0" encoding="utf-8"?>\n<stores>);
  21. open IN, '<$STORE_TMP';
  22. while (read IN,\$info, 12) {
  23. my (\$div, \$s) = unpack 'x2 i i', \$info; # read binary nums
  24. \$_ = <IN>; # Read store name
  25. chop; # Remove newline
  26. s/(\w+)/\u\L\$1/g; # Title case
  27. s/&/&amp;/g; # Fix ampersands
  28. s/"/&quot;/g; # Fix quotes
  29. printf qq(<s d="%02d" i="%d" n="%s"/>\n),\$div,\$s,\$_;
  30. }
  31. print "</stores>";
  32. EOF
  33. rm $STORE_TMP