Visit Our UNIX and Linux User Community


Help with shell scripts for Informatica and mainframes


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with shell scripts for Informatica and mainframes
# 1  
Old 03-15-2011
Help with shell scripts for Informatica and mainframes

I am poor at scripting.Can any one help me write a script which parametrizes the script here .

Code:
#!/bin/bash                                                 

`rm file1.txt`
lineCount=0
newRec=1

IFS=`echo "\n\c"`
while read line
do

	lineCount=$(($lineCount + 1))
	
	#check is it a newRec, it was default to 1
	if [ $newRec = 1 ] 
	then
		#cancel the first rec
		newRec=0
		#get the rec type
		RecType=`echo $line | cut -c51-53`
		echo "New Line $lineCount"
	fi

	echo "$lineCount|$RecType|$line" >> file1.txt
	
		
	#get the first column to test against 8 (the end of batch indicator)
	fc=`echo $line | cut -c1`

	if [ $fc = 8 ] 
	then
		newRec=1
	fi
#done
done < test_file.txt

`chmod 766 file1.txt`


Last edited by pludi; 03-15-2011 at 06:28 AM..
# 2  
Old 03-15-2011
You want to make a file with line numbers and a copy of the rectype on the left? Something using sed/awk/PERL might be more competent and simpler (too many shell outs are slow, too).
Code:
sed '
  s/^.\{50\)\(...\)/\1\
&/
  :loop
  s/\(...\)\n\(.*\)/|\1|\2\
\1/
  n
  P
  $d
  N
  s/^|...|8.*\n...\(\n.\{50\}\(...\)\)/\2\1/
  s/.*\n\(.*\n\)/\1/
  b loop
 ' | sed '
  N
  s/\n//
 '

Narrative:
  1. The first sed takes record type from very first line, sticks it on a new line in front of the first line,
  2. the next line is a branch target,
  3. sed rearranges the line to your desired output line but missing the line number plus a second line retaining the record type,
  4. prints the line number (on a new output line),
  5. prints the constructed line but not the record type on the next line in the buffer,
  6. if at EOF, exits cleaning the buffer
  7. gets the next line as second line in the buffer,
  8. captures any new record type if last was an 8 record,
  9. deletes the first line in the buffer if there are still 3,
  10. returns to the the loop tag.
  11. The second sed merges the odd line with the even line following.
# 3  
Old 03-15-2011
If you want to use parameters on your shell script, you can start with the two most important variables in it:
. input file.
. output file.
Code:
#!/bin/bash                                                 
#u Error trying to use script.
#u Usage: your_script <in_file> <out_file>
#u        Two parameters must be entered.
if [[ $# != 2 ]]; then
  sed -n '/^#u/s/..//p' your_script
fi

`rm $2`
lineCount=0
newRec=1

IFS=`echo "\n\c"`
while read line
do

	lineCount=$(($lineCount + 1))
	
	#check is it a newRec, it was default to 1
	if [ $newRec = 1 ] 
	then
		#cancel the first rec
		newRec=0
		#get the rec type
		RecType=`echo $line | cut -c51-53`
		echo "New Line $lineCount"
	fi

	echo "$lineCount|$RecType|$line" >> $2	
		
	#get the first column to test against 8 (the end of batch indicator)
	fc=`echo $line | cut -c1`

	if [ $fc = 8 ] 
	then
		newRec=1
	fi
#done
done < $1

`chmod 766 $2`


Last edited by Shell_Life; 03-15-2011 at 07:01 PM..

Previous Thread | Next Thread
Test Your Knowledge in Computers #301
Difficulty: Easy
Slackware was originally derived from the Software Linux System (SLS).
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script executed from Informatica ETL tool is spawning 2 processes for one script

Hi, I am having a shell script which has a while loop as shown below. while do sleep 60 done I am executing this script from Informatica ETL tool command task from where we can execute UNIX commands/scripts. When i do that, i am seeing 2 processes getting started for one script... (2 Replies)
Discussion started by: chekusi
2 Replies

2. Shell Programming and Scripting

Informatica post session shell script

Hi, This is regarding a issue we are facing in informatica post session. We place a shell script in informatica job. The shell script will need to upload a dummy file to another server.The shell script is running fine.However in informatica job not completing and throwing error It's... (1 Reply)
Discussion started by: nag_sathi
1 Replies

3. Cybersecurity

Using sftp from mainframes to other server

HI all I need a script that would take the file from a mainframe to another server.Presently i am using a ndm but i am not knowing what the changes would be required to change to sftp. Can you please provide some code that would be helpful Thanks (7 Replies)
Discussion started by: msandeep27
7 Replies

4. Shell Programming and Scripting

Help with Informatica Backend Shell Script

Request Any one of your to provide me a script which does the following in a single unix script. Basically Users will load data in SHARED LINK everyday, should write a UNIX SCRIPT which will ........ 1) Unix script should Open the LINK (FTP) 2) Each DIRECTORY in the link contains many... (0 Replies)
Discussion started by: informaticalabs
0 Replies

5. Shell Programming and Scripting

calling 'n' number of shell scripts based on dependency in one shell script.

Hello gurus, I have three korn shell script 3.1, 3.2, 3.3. I would like to call three shell script in one shell script. i m looking for something like this call 3.1; If 3.1 = "complete" then call 3.2; if 3.2 = ''COMPlete" then call 3.3; else exit The... (1 Reply)
Discussion started by: shashi369
1 Replies

6. UNIX for Dummies Questions & Answers

FTP to Mainframes from Unix

Hi, Iam new to unix.I have 3 files to be FTPied to Mainframe from Unix(Sun Solaries Unix). Sample record in one file is as shown below. 123▀Raj▀123-456▀jack▀▀ 124▀Rajesh▀123-457▀jacm▀▀ In the above file the records are seperated by delimitter "▀". When I used the below script to FTP from Unix... (3 Replies)
Discussion started by: Rahul321
3 Replies

7. Shell Programming and Scripting

How to FTP file usinf shell script to Mainframes

Hi , Please help me FTP an output file to mainframes using Mainframes. I have no idea how to FTP to mainframes. :( I need to deploy my code by next week. The code is ready but the client's requirement is that i need to ftp all the output file to the mainframes server. I created the dataset... (1 Reply)
Discussion started by: deepthimathew
1 Replies

8. Shell Programming and Scripting

Reg: Shell script ran using informatica

Hi all, I am not sure whether this is the right place to ask this question...:) I am working in Informatica PowerCenter 8.1.1 tool and my server is on UNIX. I have got a shell script to copy files from one folder to another. When I run the script directly from UNIX prompt it is taking 60... (0 Replies)
Discussion started by: sam99
0 Replies

9. AIX

Difference between writing Unix Shell script and AIX Shell Scripts

Hi, Please give me the detailed Differences between writing Unix Shell script and AIX Shell Scripts. Thanks in advance..... (0 Replies)
Discussion started by: haroonec
0 Replies

10. UNIX for Dummies Questions & Answers

FTP file to Mainframes

Hi, Can somebody please share a sample Korn shell script that will FTP a file from an Unix box to a region in Mainframe.It will be of great help if i can get this script ASAP.Or atleast give me a hint on how to do it. Thanks, Gopi (1 Reply)
Discussion started by: bhgopi
1 Replies

Featured Tech Videos