Skip to main content
Dominique Sacre
Rocketeer
Feb 23, 2011 12:26 AM UTC

How to call batch script in JCL/Cobol in Net Express

[Migrated content. Thread originally posted on 22 February 2011]

Hi,

can we call batch script in JCL/Cobol in Net Express 5.1.
If yes, How?

Thanks and Regards
Cheeta LM

    8 replies

    Dominique Sacre
    Rocketeer
    Feb 23, 2011 12:36 AM UTC

    [Migrated content. Thread originally posted on 22 February 2011]

    Hi,

    can we call batch script in JCL/Cobol in Net Express 5.1.
    If yes, How?

    Thanks and Regards
    Cheeta LM
    Create a second program compiled as ASCII without any of the mainframe compiler dialects. Call this program from the mainframe program. If you need to pass parms in you'll need to convert parms from EBCDIC to ASCII using a call to _CODESET and then use a x'91' function 35 library routine to shell to dos and execute the BAT file
    Dominique Sacre
    Rocketeer
    Feb 23, 2011 12:43 AM UTC

    [Migrated content. Thread originally posted on 22 February 2011]

    Hi,

    can we call batch script in JCL/Cobol in Net Express 5.1.
    If yes, How?

    Thanks and Regards
    Cheeta LM
    Using the x'91' Function 35 will work but does not give you much control. The return code from this call only indicates that the command file you executed started correctly but does not capture the success or failure of the scipt itself.

    The use of a Pipe file allows you to execute a command file and if opened I-O also allows the program to capture any STDOUT from the script itself.

    Use of Pipe files also makes the code more portable as with due consideration it will work in both Windows and Unix.

    You should be able to find details of using the Pipe file in the Net Express Help.

    Regards
    Gary
    Dominique Sacre
    Rocketeer
    Feb 23, 2011 12:43 AM UTC

    [Migrated content. Thread originally posted on 22 February 2011]

    Hi,

    can we call batch script in JCL/Cobol in Net Express 5.1.
    If yes, How?

    Thanks and Regards
    Cheeta LM
    Using the x'91' Function 35 will work but does not give you much control. The return code from this call only indicates that the command file you executed started correctly but does not capture the success or failure of the scipt itself.

    The use of a Pipe file allows you to execute a command file and if opened I-O also allows the program to capture any STDOUT from the script itself.

    Use of Pipe files also makes the code more portable as with due consideration it will work in both Windows and Unix.

    You should be able to find details of using the Pipe file in the Net Express Help.

    Regards
    Gary
    Dominique Sacre
    Rocketeer
    Feb 23, 2011 12:43 AM UTC

    [Migrated content. Thread originally posted on 22 February 2011]

    Hi,

    can we call batch script in JCL/Cobol in Net Express 5.1.
    If yes, How?

    Thanks and Regards
    Cheeta LM
    Using the x'91' Function 35 will work but does not give you much control. The return code from this call only indicates that the command file you executed started correctly but does not capture the success or failure of the scipt itself.

    The use of a Pipe file allows you to execute a command file and if opened I-O also allows the program to capture any STDOUT from the script itself.

    Use of Pipe files also makes the code more portable as with due consideration it will work in both Windows and Unix.

    You should be able to find details of using the Pipe file in the Net Express Help.

    Regards
    Gary
    Dominique Sacre
    Rocketeer
    Feb 23, 2011 12:59 AM UTC

    [Migrated content. Thread originally posted on 22 February 2011]

    Hi,

    can we call batch script in JCL/Cobol in Net Express 5.1.
    If yes, How?

    Thanks and Regards
    Cheeta LM
    For Pipe read Pipes. Its been a long day!

    To make up for it I have C&P'd the section from the help.

    Setting Up Pipes
    You can use COBOL file syntax to launch another process (such as the dir command) and either write data to the standard input of that other process or read data coming from the standard output of the other process. The COBOL file organization must be either LINE SEQUENTIAL or RECORD SEQUENTIAL.

    Output Pipes
    To launch a process and write data to its standard input, the filename must consist of the > sign followed by the name of the command. The file should be opened for output.

    For example:

    select output-file
    assign to ">cmd /c sort"
    organization is line sequential.
    fd output-file.
    01 output-file-record pic x(10).
    procedure division.
    open output output-file
    write output-file-record from "Charles"
    write output-file-record from "Bill"
    write output-file-record from "Alan"
    close output-file.
    Input Pipes
    To launch a process and read data from its standard output, the filename must consist of the "lt" symbol followed by the name of the command. The file should be opened for input.

    For example:

    select input-file
    assign to "
    organization is line sequential.
    ...
    open input input-file
    read input-file
    In this example the program launches the dir process and reads in the first line that it writes to its standard output.

    Two-way Pipes
    Two-way pipes combine the functions of input and output pipes. To use a two-way pipe, the filename must consist of the pipe symbol (|) followed by the name of the command. The file should be opened for inpit-output i-o.

    For example:

    select i-o-file
    assign to "| cmd /c sort"
    organization is line sequential.
    fd i-o-file.
    01 i-o-file-record pic x(20).
    procedure division.
    open i-o i-o-file
    write i-o-file-record from "Hello world"
    write i-o-file-record from all "A"
    write i-o-file-record from all "Z"
    write i-o-file-record from x"1a"
    perform until exit
    read i-o-file
    at end
    exit perform
    end-read
    display i-o-file-record
    end-perform
    close i-o-file
    In this example, the program launches the sort process and passes it three lines of text, followed by an end-of-file marker. The program then reads all three lines back from the standard output of the sort process.

    Dominique Sacre
    Rocketeer
    Nov 11, 2011 12:03 PM UTC

    [Migrated content. Thread originally posted on 22 February 2011]

    Hi,

    can we call batch script in JCL/Cobol in Net Express 5.1.
    If yes, How?

    Thanks and Regards
    Cheeta LM
    I have a similar problem and don't know how to solve it.
    I'm using Server Express 5.1 with HP-UX 11.31.

    I need to translate a string from iso8859-1 to utf-8.
    I wrote a php script for that. the script needs one argument (the string) and returns the string in utf8.
    The script has the path /usr/local/bin/iso2utf8.php.
    I wrote the following in cobol but it didn't work.
    What's wrong?
    Thanks Roland

    input-output section.
    select i-o-file
    assign to "|/usr/local/bin/iso2utf8.php "
    organization is line sequential.
    *-================================================================
    data division.
    file section.
    *-----------------------------------------------------------------
    fd i-o-file.
    01 i-o-file-record pic x(80).
    *-================================================================
    open i-o i-o-file.
    write i-o-file-record from "Glas Trösch AG".
    read i-o-file.
    move i-o-file-record to w01-ws-out-customerReference.
    close i-o-file.
    Chris Glazier
    Moderator
    Nov 11, 2011 6:46 PM UTC

    [Migrated content. Thread originally posted on 22 February 2011]

    Hi,

    can we call batch script in JCL/Cobol in Net Express 5.1.
    If yes, How?

    Thanks and Regards
    Cheeta LM
    I am not all that familiar with PHP but I believe that because this is a scripting language, it requires either a web server or other translator in order to run it.

    Can you run it from a shell by executing the command:
    /usr/local/bin/iso2utf8.php

    If you cannot run it from the shell or command line then you cannot create a pipe to it in the manner that you are attempting.

    Is there a php command processor that needs to be run, e.g. php /usr/local/bin/iso2utf8.php?

    Perhaps someone with more knowledge of PHP could chime in here?

    Dominique Sacre
    Rocketeer
    Nov 11, 2011 8:54 PM UTC

    [Migrated content. Thread originally posted on 22 February 2011]

    Hi,

    can we call batch script in JCL/Cobol in Net Express 5.1.
    If yes, How?

    Thanks and Regards
    Cheeta LM
    Chris Glazier originally wrote:
    I am not all that familiar with PHP but I believe that because this is a scripting language, it requires either a web server or other translator in order to run it.


    Yes - it would be executed by the PHP interpreter (whether standalone or under a web server is immaterial). But that could happen implicitly, if the file starts with an interpreter line.


    Can you run it from a shell by executing the command:
    /usr/local/bin/iso2utf8.php


    That should work if:

    - iso2utf8.php starts with an appropriate interpreter line (eg "#! /usr/bin/php")
    - iso2utf8.php is readable and executable by the user
    - the specified interpreter exists and is executable by the user
    - the specified interpreter is an installation of the PHP interpreter that was compiled with support for the CLI SAPI

    (See the PHP documentation for more details.)

    If it can be executed directly from the user's shell, then it should work as a pipe-file from an ordinary COBOL program run by the same user. (PHP wouldn't be my choice for this job - it seems far too heavy for the problem as described - but it ought to work.)

    However, it might still not work under ES (which wasn't part of this poster's question, but is relevant to the original question in the thread), because processes there will likely be running under a different user ID, etc. Getting this sort of thing to work may require a good understanding of the Unix programming model and how all the pieces fit together.