• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • EDTF and End-of-Line Delimiters, Take Two

    August 30, 2006 Hey, Ted

    In EDTF and End-of-Line Delimiters, you demonstrated a method for removing carriage-return characters from end-of-line delimiters in stream files. Unfortunately, your method only works in interactive jobs. I need to do the same operation on a file that I need to FTP. Do you have a way to remove these characters in batch?

    –Chuck

    You have pointed out yet another violation of Holt’s Law of Interactive Programs, which states: “The problem with interactive programs is that you can’t run them in batch.” I have a few methods for you, Chuck. First, here’s one from Shalom Carmel, a really sharp guy who reads this newsletter and who has contributed several good ideas.

    Shalom suggested using the sed utility, which is a batch editor, under Qshell or PASE. The sed tool is good for making changes to text files when you can’t be present to win. Here is Shalom’s solution.

    sed 's/.$//' file1 > file2
    

    Sed reads file1 and writes the converted data to file2. The s subcommand tells sed to substitute one expression with another one. The expressions are coded between the slashes. The period before the dollar sign is a wildcard that can match any character. The dollar sign represents the end of the line. Therefore, the first expression means that the character immediately preceding the end of line, which is always a carriage-return, is to be substituted with an empty expression.

    Shalom goes on to say, “The thing to watch is the codepage of the result file. Qshell will create the new file with the codepage of the job, while PASE will create it with the default ASCII codepage. More simple yet powerful sed commands can be found at www.student.northpark.edu/pemente/sed/sed1line.txt.”

    Thanks, Shalom. Here is an easier Qshell method.

    cat file1 >file2
    

    I’m not sure why this one works. The cat utility seems to know that lines can be ended with either CR/LF or LF alone and accepts a file with either delimiter. However, when Qshell writes the file, it uses the LF character only to terminate the records, according to the Qshell standard.

    I’ve shown these commands as they would be entered into a shell script. To run them from CL, embed them in the QSH command.

    QSH CMD('sed ''s/.$//'' file1 > file2')
    QSH CMD('cat file1 >file2')
    

    Last, here is a method that uses CL commands.

    CRTPF FILE(QTEMP/SAVE) RCDLEN(256)
    
    CPYFRMSTMF FROMSTMF(file1)
               TOMBR('/QSYS.LIB/QTEMP.LIB/SAVE.FILE/SAVE.MBR')
               MBROPT(*REPLACE)
    
    CPYTOSTMF FROMMBR('/QSYS.LIB/QTEMP.LIB/SAVE.FILE/SAVE.MBR')
              TOSTMF(file2)
              ENDLINFMT(*LF)
    

    The default behavior of Copy From Stream File (CPYFRMSTMF) is to accept any combination of carriage-return and line-feed characters as end-of-file markers. You can use the ENDLINFMT parameter to check for a certain delimiter. In this example, there is no need to use ENDLINFMT. So, CPYFRMSTMF reads the stream file and writes to a scratch database file. Then Copy To Stream File writes to a stream file, terminating each line with a line-feed character.

    –Ted

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    WorksRight Software

    Do you need area code information?
    Do you need ZIP Code information?
    Do you need ZIP+4 information?
    Do you need city name information?
    Do you need county information?
    Do you need a nearest dealer locator system?

    We can HELP! We have affordable AS/400 software and data to do all of the above. Whether you need a simple city name retrieval system or a sophisticated CASS postal coding system, we have it for you!

    The ZIP/CITY system is based on 5-digit ZIP Codes. You can retrieve city names, state names, county names, area codes, time zones, latitude, longitude, and more just by knowing the ZIP Code. We supply information on all the latest area code changes. A nearest dealer locator function is also included. ZIP/CITY includes software, data, monthly updates, and unlimited support. The cost is $495 per year.

    PER/ZIP4 is a sophisticated CASS certified postal coding system for assigning ZIP Codes, ZIP+4, carrier route, and delivery point codes. PER/ZIP4 also provides county names and FIPS codes. PER/ZIP4 can be used interactively, in batch, and with callable programs. PER/ZIP4 includes software, data, monthly updates, and unlimited support. The cost is $3,900 for the first year, and $1,950 for renewal.

    Just call us and we’ll arrange for 30 days FREE use of either ZIP/CITY or PER/ZIP4.

    WorksRight Software, Inc.
    Phone: 601-856-8337
    Fax: 601-856-9432
    Email: software@worksright.com
    Website: www.worksright.com

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    Lakeview Technology:  A new standard for ease of use in iSeries High Availability
    Computer Keyes:  Rapidly convert *SCS printer files into black and white or full color PDF documents
    COMMON:  Join us at the Fall 2006 conference, September 17-21, in Miami Beach, Florida

    Federal Trade Commission to Weigh In on Net Neutrality Bang for the Buck: Enterprise i5 Servers Versus the Competition

    Leave a Reply Cancel reply

Volume 6, Number 32 -- August 30, 2006
THIS ISSUE SPONSORED BY:

T.L. Ashford
Asymex
COMMON

Table of Contents

  • Undocumented Debugger Function
  • EDTF and End-of-Line Delimiters, Take Two
  • Admin Alert: Four iSeries Access Tips for Windows Professionals

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • To Comfort The Afflicted And Afflict The Comfortable
  • How FalconStor Is Reinventing Itself, And Why IBM Noticed
  • Guru: When Procedure Driven RPG Really Works
  • Vendors Fill In The Gaps With IBM’s New MFA Solution
  • IBM i PTF Guide, Volume 27, Number 27
  • With Power11, Power Systems “Go To Eleven”
  • With Subscription Price, IBM i P20 And P30 Tiers Get Bigger Bundles
  • Izzi Buys CNX, Eyes Valence Port To System Z
  • IBM i Shops “Attacking” Security Concerns, Study Shows
  • IBM i PTF Guide, Volume 27, Number 26

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle