txwaiting4u
Programmer
I am a complete newbie at UNIX scripting. I have only written some really basic scripts but now have to figure out a solution that our ETL solution cannot do. We use ksh. This is my need:
1. Parameters passed to script for the following:
xferin ---> the directory where the input file is to be read from
src ---> the directory where the 2 output files should be written in format MYFILE1_EXTRACT_ccyymmdd.dat and MYFILE2_EXTRACT_ccyymmdd.dat
arch ---> the directory where the input file will be zipped and archived to
extractfilename ---> the input file to the script to be read in format #####_MYFILE_EXTRACT_ccyymmdd.dat (##### is actually 30 characters long for)
2. Read each line of the input file. If the rec type in column 29 (1 character) = 1 then write the line to output file 1 (MYFILE1). If rec type = 2 then write the line to output file 2. If rec type is anything other than 1 or 2, ignore record (shouldn't occur but need for exception handling).
3. The input file is in binary but the rec type is character.
4. The output files must remain in binary.
5. All files are .dat files -- (like .txt) -- with no delimiters. Fields up to the rec type are fixed length.
Probably alot more info than anyone needs but not sure if I have to consider some of these things in ksh scripting. I'm a mainframer expert but learning tons about UNIX these days.
Any bits or pieces of a solution would be a start. I have worked for the last few hours and my script is appalling in regards to syntax errors. Also, when executing the script, how do you pass the parameters into the script? I have been trying --> ksh my_script.sh|param1|param2|...
Thank you in advance. I will now continue scouring the rest of the forum.
Sheila
1. Parameters passed to script for the following:
xferin ---> the directory where the input file is to be read from
src ---> the directory where the 2 output files should be written in format MYFILE1_EXTRACT_ccyymmdd.dat and MYFILE2_EXTRACT_ccyymmdd.dat
arch ---> the directory where the input file will be zipped and archived to
extractfilename ---> the input file to the script to be read in format #####_MYFILE_EXTRACT_ccyymmdd.dat (##### is actually 30 characters long for)
2. Read each line of the input file. If the rec type in column 29 (1 character) = 1 then write the line to output file 1 (MYFILE1). If rec type = 2 then write the line to output file 2. If rec type is anything other than 1 or 2, ignore record (shouldn't occur but need for exception handling).
3. The input file is in binary but the rec type is character.
4. The output files must remain in binary.
5. All files are .dat files -- (like .txt) -- with no delimiters. Fields up to the rec type are fixed length.
Probably alot more info than anyone needs but not sure if I have to consider some of these things in ksh scripting. I'm a mainframer expert but learning tons about UNIX these days.
Any bits or pieces of a solution would be a start. I have worked for the last few hours and my script is appalling in regards to syntax errors. Also, when executing the script, how do you pass the parameters into the script? I have been trying --> ksh my_script.sh|param1|param2|...
Thank you in advance. I will now continue scouring the rest of the forum.
Sheila