Just to close the loop, here is what I ended up with thanks to John's sample.   
I must admit I do not know all the nuances of coding unix scripts/complex 
commands.   In the end, I was able to accomplish what I set out to do.

SH                                                                        
cd /VSM01A/sas/ &&                                                        
mv sassw.config sassw.config.orig &&                                      
cat sassw.config.orig |                                                   
iconv -f ISO8859-1 -t IBM-1047 |                                          
sed -E 's#/u/Maintsas#/vendor/sas#g' |                                    
iconv -f IBM-1047 -t ISO8859-1 >new.file && mv new.file sassw.config &&   
cat -W filecodeset=UTF-8 sassw.config                                     

_________________________________________________________________
Dave Jousma
Assistant Vice President, Mainframe Engineering
[email protected]
1830 East Paris, Grand Rapids, MI  49546 MD RSCB2H
p 616.653.8429
f 616.653.2717


-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[email protected]] On Behalf 
Of John McKown
Sent: Friday, February 19, 2016 3:54 PM
To: [email protected]
Subject: Re: JCL sample needed

On Fri, Feb 19, 2016 at 2:32 PM, Jousma, David <[email protected]> wrote:

> All,
>
> Been scratching my head all afternoon on this.   I have a text file in
> mainframe unix filesystem that is ascii format.   Bottom line is that in
> batch, I need to do a find/replace for certain data in it.
>
> Interactively, I know I can do it via ISPF with the EA(edit ASCII)
> command.   But I need to do it in batch, so unless someone has a clever way
> to do it, I'm thinking I need to copy it out to flat file, convert to 
> EBCDIC, make the changes, and then copy it back to the unix filesystem 
> from whence it came, converting it back to ascii and doing it in batch.
>
> Tried ICETOOL with OUTREC...BUILD...TRAN=ATOE, tried FTP, but don't 
> seem to have the correct incantation to make that work, and I've tried 
> OGETX, but no good results.
>
> Does anyone have some hints/tips to accomplish?
>
> Thanks, Dave
>


​Run a UNIX step using BPXBATCH. Use the //STDPARM DD to pass in a really long 
parameter line to do something like:

//CHANGE EXEC PGM=BPXBATCH,REGION=0M
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//STDIN DD *
//STDPARM DD *
SH ​

​cd /directory/containing &&
cat ascii.file.txt |
iconv -f ISO8859-1 -t IBM-1047 |
sed -E 's/BUBBA/TROUBLE/g' ​ |
iconv -f IBM-1047 -t ISO8859-1 >new.file && mv new.file ascii.file.txt
/*
//


This changes all occurrences of BUBBA to TROUBLE. This would be equivalent to 
the ISPF edit command: CHANGE 'BUBBA' 'TROUBLE' ALL . Note for this simple 
case, the -E (extended regexp) is not needed. If you could use some help with 
regular expressions, this is a good site:
http://www.regular-expressions.info/tutorial.html . Or just post the ISPF 
CHANGE command that you'd like emulated using "sed". You could have multiple 
'sed' commands to do multiple edits. Or you could do a single sed with multiple 
changes.

Note in the above, the multiple lines are all "mushed together" as if it were a 
single long line. That is, the end-of-line doesn't indicate _anything_ special. 
In fact, it is eliminated. That's why I have the && and
| between commands. The && ensures that the command sequence stops on an
error. And, of course, the pipe character, |, passes the data stream along.


--
The man has the intellect of a lobotomized turtle.

Maranatha! <><
John McKown

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions, send email to 
[email protected] with the message: INFO IBM-MAIN

This e-mail transmission contains information that is confidential and may be 
privileged.   It is intended only for the addressee(s) named above. If you 
receive this e-mail in error, please do not read, copy or disseminate it in any 
manner. If you are not the intended recipient, any disclosure, copying, 
distribution or use of the contents of this information is prohibited. Please 
reply to the message immediately by informing the sender that the message was 
misdirected. After replying, please erase it from your computer system. Your 
assistance in correcting this error is appreciated.


----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to