If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Need help with this script! PLEEEEASE!!!

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-25-04, 17:42
Armando Soto Armando Soto is offline
Registered User
 
Join Date: Oct 2004
Posts: 8
Unhappy Need help with this script! PLEEEEASE!!!

I have a script that I dont know what it is doing. Can any one tell me what this script is doing? Please? here is the script with the lines numbered.

1 #!usr/bin/ksh
2 date +%m%d%y%H%M >invdte
3 exec <invdte
4 read dte
5 cp /test/appl_from/810S /test/appl_from/810S-$dte.jic
6 cp /test/appl_from/base810S /test/appl_from/A3810S
7 cp /test/appl_from/base810S /test/appl_from/3M810S
8 >810a.wrk
9 sig="XX"
10 A3=" "
11 fil="XX"
12 t=0
13 usxx=0
14 usab=0
15 us3M=0
16 id[300]="end"
17 cat /test/appl_from/810S |tr "|" "11" >810a.wrk
18 exec <810a.wrk
19 while read a b c d e f g h i j
20 do
21 ((t=t+1))
22 if test "$a" = "ENV"
23 then
24 echo "$g $e"
25 if test "$h" = "X12"
26 then sig="$g"
27 fi
28 fi
29 id[$t]="$sig"
30 done
31
32 exec </test/appl_from/810S
33 t=0
34 while read a
35 do
36 ((t=t+1))
37 fil="XX"
38 usxx=1
39 if test ${id[$t]} = "ABBOTT"
40 then fil="A3"
41 usab=1
42 fi
43 if test ${id[$t]} = "3M"
44 then fil="3M"
45 us3m=1
46 fi
47 echo $a >>/test/appl_from/"$fil"810S
48 if test "$fil" = "XX"
49 then
50 echo "cannot assign inv for ${id[$t]}"
51 fi
52 done
53
54 if test $usab = "1"
55 then
56 echo "A3 file exists"
57 fi
58
59 if test "$us3M" = "1"
60 then
61 echo "3M file exists"
62 fi
63 mv /test/appl_from/810S /test/appl_from/810S-"$dte".fil
64 exit
Reply With Quote
  #2 (permalink)  
Old 10-26-04, 08:42
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
Cool

Here you will find what you need.
__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
  #3 (permalink)  
Old 10-26-04, 10:18
Armando Soto Armando Soto is offline
Registered User
 
Join Date: Oct 2004
Posts: 8
NEED HELP with this script

I am not a unix person, nor do I pretend to be. This was a script that prepares invoices for EDI transmission but it doesnt work. I believe it to be becasue of the first 20 lines but I am not sure what these first 20 lines are doing. Can someone please translate this into english so us non unix users can understand what it is doing? I appreciate any help I can get.
Please.
Thank you.
Reply With Quote
  #4 (permalink)  
Old 10-26-04, 13:35
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,454
The script doesn't make a whole lot of sense to me - but here goes:

line 2-4: obtain the current time to use later

line 5: create a copy of /test/appl_from/810S; use the timestamp to distinguish the file name

line 6-7: create two copies of /test/appl_from/base810S

line 8: create an empty file called 810a.wrk

...

line 17: take the file /test/appl_from/810S and replace all "|"s with "1"s; put the result into 810a.wrk

line 19-30: look at each line of 810a.wrk; if it begins with "ENV" and there's "X12" in the 8th field save the 7th field

line 32-52: read every line of /test/appl_from/810S; if the 7th field of that line (as saved before) is "ABBOTT" append that line to the file //test/appl_from/A3810S; if the 7th field is "3M" then append it to /test/appl_from/3M810S

Hope this helps you...
Reply With Quote
  #5 (permalink)  
Old 10-26-04, 15:01
Armando Soto Armando Soto is offline
Registered User
 
Join Date: Oct 2004
Posts: 8
needs help with script.

Yes it does help. It does make some sense. thank you for your input. I appreciate it.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On