Skip to main content
Feb 9, 2018 2:55 AM UTC

Output from GIT always coming back in ASCII

I have written a REXX exec to inface to GIT.

Specifically I use BPXWUNIX to issue my commands. The issue I have is the output from the command is always in ASCII (ISO-8859-1). Forcing me the perform a conversion before I can read the results.

This doesn’t happen if I issue the command in OMVS.

I’ve tried using BPXWUNIX using redirection

eg    x=BPXWUNIX('git status >output.txt',,,,,1)  

and coding the stdout in the function call

eg   x=BPXWUNIX('git status',,'output.',,,1) 

I have my profile setup with

export _CEE_RUNOPTS="FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"
export _BPXK_AUTOCVT=ON
export _TAG_REDIR_ERR=TXT
export _TAG_REDIR_IN=TXT
export _TAG_REDIR_OUT=TXT

Does anyone know how I can get the system/git to perform the conversion to EBCDIC before I get the output ?

Regards,
Gary

    25 replies

    Tatiana Balaburkina
    Rocketeer
    Feb 15, 2018 5:32 AM UTC

    I have created a sample program that I’m hoping someone will run on their system and publish the results here.

    /* REXX */
    env.0=1
    env.1='HOME=/u/u700215’
    command=“echo ‘Start GIT Status’;”,
    “cd ~/zGIT-Repository/COPYX;”,
    “git status;”,
    "echo ‘End GIT Status’;"
    rcode=bpxwunix(command,‘stdout.’,‘stderr.’,‘env.’,1)
    if rcode>0 then say 'Rcode from bpxwunix='rcode
    say
    say copies(‘STDOUT–’,5)
    do i=1 to stdout.0
    say stdout.i
    end
    say copies(‘STDERR–’,5)
    do i=1 to stderr.0
    say stderr.i
    end

    Line 3 will need to be undated with your home directory,
    Line 5 should be changed so the “cd” points to a git repository.

    My results are:

    STDOUT–STDOUT–STDOUT–STDOUT–STDOUT–
    Start GIT Status
    |>:::/>:::_/:::::>?:::>:::?::?__:::::?:,:>::::::::?::::%:/>:End GIT Status
    STDERR–STDERR–STDERR–STDERR–STDERR–

    What do you get ???

    Regards,
    Gary

    Hi Gary,

    git works over bash-4.3. When you run git via REXX this way, bash-4.3 is not started and these variables are not exported:

    export _BPXK_AUTOCVT=ON
    export _CEE_RUNOPTS="FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"
    export _TAG_REDIR_ERR=txt
    export _TAG_REDIR_IN=txt
    export _TAG_REDIR_OUT=txt

    Feb 15, 2018 9:35 AM UTC

    I have written a REXX exec to inface to GIT.

    Specifically I use BPXWUNIX to issue my commands. The issue I have is the output from the command is always in ASCII (ISO-8859-1). Forcing me the perform a conversion before I can read the results.

    This doesn’t happen if I issue the command in OMVS.

    I’ve tried using BPXWUNIX using redirection

    eg    x=BPXWUNIX('git status >output.txt',,,,,1)  
    

    and coding the stdout in the function call

    eg   x=BPXWUNIX('git status',,'output.',,,1) 
    

    I have my profile setup with

    export _CEE_RUNOPTS="FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"
    export _BPXK_AUTOCVT=ON
    export _TAG_REDIR_ERR=TXT
    export _TAG_REDIR_IN=TXT
    export _TAG_REDIR_OUT=TXT

    Does anyone know how I can get the system/git to perform the conversion to EBCDIC before I get the output ?

    Regards,
    Gary

    Hi Tatyana,

    Thanks for the feedback. So what do you suggest ?

    While I’m no Unix expert, I believe our wrapper code does setup bash 4.3. How can I tell ?

    If bash 4.3 is not being used via this REXX, what do I need to do get it working ?

    Regards,
    Gary

    Feb 16, 2018 12:24 PM UTC

    I have written a REXX exec to inface to GIT.

    Specifically I use BPXWUNIX to issue my commands. The issue I have is the output from the command is always in ASCII (ISO-8859-1). Forcing me the perform a conversion before I can read the results.

    This doesn’t happen if I issue the command in OMVS.

    I’ve tried using BPXWUNIX using redirection

    eg    x=BPXWUNIX('git status >output.txt',,,,,1)  
    

    and coding the stdout in the function call

    eg   x=BPXWUNIX('git status',,'output.',,,1) 
    

    I have my profile setup with

    export _CEE_RUNOPTS="FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"
    export _BPXK_AUTOCVT=ON
    export _TAG_REDIR_ERR=TXT
    export _TAG_REDIR_IN=TXT
    export _TAG_REDIR_OUT=TXT

    Does anyone know how I can get the system/git to perform the conversion to EBCDIC before I get the output ?

    Regards,
    Gary

    I tried to figure out what’s going wrong.

    So I created ~/zGIT-Repository/COPYX and there I did a git init.

    Then I wrote a script setting all the variables as given in git/share/doc/git/2.3.5/README.ZOS

    #! /bin/sh
    ...
    git status
    

    When calling it from UNIX shell output is:

    On branch master

    Initial commit

    nothing to commit (create/copy files and use “git add” to track)

    So all seems good.

    Now I called above script using Gary’s REXX, and I get ASCII garbage as output from the git status command.

    Now comes the even stranger part:

    When I insert a curl command like this

    curl -s http://www.yahoo.com

    just before the git command then the REXX runs fine, i.e. no garbage at all.

    I have no idea why something like this happens.

    Feb 20, 2018 3:10 AM UTC

    I have written a REXX exec to inface to GIT.

    Specifically I use BPXWUNIX to issue my commands. The issue I have is the output from the command is always in ASCII (ISO-8859-1). Forcing me the perform a conversion before I can read the results.

    This doesn’t happen if I issue the command in OMVS.

    I’ve tried using BPXWUNIX using redirection

    eg    x=BPXWUNIX('git status >output.txt',,,,,1)  
    

    and coding the stdout in the function call

    eg   x=BPXWUNIX('git status',,'output.',,,1) 
    

    I have my profile setup with

    export _CEE_RUNOPTS="FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"
    export _BPXK_AUTOCVT=ON
    export _TAG_REDIR_ERR=TXT
    export _TAG_REDIR_IN=TXT
    export _TAG_REDIR_OUT=TXT

    Does anyone know how I can get the system/git to perform the conversion to EBCDIC before I get the output ?

    Regards,
    Gary

    Hi Manfred,

    So what you are saying is if you pass the following string to to BPXWUNIX

    echo ‘Start GIT Status’ ; cd ~/zGIT-Repository/COPYX ; git status ; echo ‘End GIT Status’

    The output from the git command comes back in ASCII, but if you pass the string

    echo ‘Start GIT Status’ ; cd ~/zGIT-Repository/COPYX ;curl -s http://www.yahoo.com ; git status ; echo ‘End GIT Status’

    The output from the git command comes back in EBCDIC

    Is that correct ?

    Gary

    Feb 21, 2018 4:08 PM UTC

    Hi Manfred,

    So what you are saying is if you pass the following string to to BPXWUNIX

    echo ‘Start GIT Status’ ; cd ~/zGIT-Repository/COPYX ; git status ; echo ‘End GIT Status’

    The output from the git command comes back in ASCII, but if you pass the string

    echo ‘Start GIT Status’ ; cd ~/zGIT-Repository/COPYX ;curl -s http://www.yahoo.com ; git status ; echo ‘End GIT Status’

    The output from the git command comes back in EBCDIC

    Is that correct ?

    Gary

    Hi Gary,
    Admittedly confusing but this is what I observed. Actually, I have no consistent theory what’s going on here.

    Manfred

    Feb 22, 2018 12:22 PM UTC

    I have written a REXX exec to inface to GIT.

    Specifically I use BPXWUNIX to issue my commands. The issue I have is the output from the command is always in ASCII (ISO-8859-1). Forcing me the perform a conversion before I can read the results.

    This doesn’t happen if I issue the command in OMVS.

    I’ve tried using BPXWUNIX using redirection

    eg    x=BPXWUNIX('git status >output.txt',,,,,1)  
    

    and coding the stdout in the function call

    eg   x=BPXWUNIX('git status',,'output.',,,1) 
    

    I have my profile setup with

    export _CEE_RUNOPTS="FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"
    export _BPXK_AUTOCVT=ON
    export _TAG_REDIR_ERR=TXT
    export _TAG_REDIR_IN=TXT
    export _TAG_REDIR_OUT=TXT

    Does anyone know how I can get the system/git to perform the conversion to EBCDIC before I get the output ?

    Regards,
    Gary

    Hi Tatyana,
    You could test like follows:

    1. Have git, bash, perl, unzip and curl all in a certain directory tree. In my case it is /u/manfred/rocket.

    2. In /u/manfred/rocket I have a script git_env which contains:

    ROCKET=/u/manfred/rocket
    export PATH=$ROCKET/bin:$PATH
    export _BPXK_AUTOCVT=ON
    export _CEE_RUNOPTS="FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"
    export _TAG_REDIR_ERR=txt
    export _TAG_REDIR_IN=txt
    export _TAG_REDIR_OUT=txt

    and use this to source in the environment, i.e. . /u/manfred/rocket/rocket_env

    1. Go to a directory with a git repository and run
      git status

    This should worke fine.

    1. In a batch job run this REXX:

    /* REXX */
    env.0=1
    env.1=‘HOME=/u/manfred’

    /* This is a test case to show Rocket that something is wrong
    */

    BASE = “/u/manfred"
    ROCKET_BASE = BASE||”/rocket"

    command=". “ROCKET_BASE”/rocket_env;",
    ‘curl’,
    ‘http://www.yahoo.com;’,
    “cd /u/manfred/zGIT-Repository/COPYX;”,
    “git status;”,
    “echo ‘End GIT Status’;”

    rcode=bpxwunix(command,‘stdout.’,‘stderr.’,‘env.’,1)
    if rcode>0 then say 'Rcode from bpxwunix='rcode
    say
    say copies(‘STDOUT-’,5)
    do i=1 to stdout.0
    say stdout.i
    end
    say copies(‘STDERR-’,5)
    do i=1 to stderr.0
    say stderr.i
    end

    This should run fine as well. Note that there is an invocation of curl before doing git status

    1. Delete the two curl related lines and run the job again.
      Now git output is ASCII gibberish.

    If you need a sample of a complete batch job just tell me. I could post it here or send it do you via mail. Whatever you like.

    Manfred

    Mar 5, 2018 3:29 PM UTC

    I have written a REXX exec to inface to GIT.

    Specifically I use BPXWUNIX to issue my commands. The issue I have is the output from the command is always in ASCII (ISO-8859-1). Forcing me the perform a conversion before I can read the results.

    This doesn’t happen if I issue the command in OMVS.

    I’ve tried using BPXWUNIX using redirection

    eg    x=BPXWUNIX('git status >output.txt',,,,,1)  
    

    and coding the stdout in the function call

    eg   x=BPXWUNIX('git status',,'output.',,,1) 
    

    I have my profile setup with

    export _CEE_RUNOPTS="FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"
    export _BPXK_AUTOCVT=ON
    export _TAG_REDIR_ERR=TXT
    export _TAG_REDIR_IN=TXT
    export _TAG_REDIR_OUT=TXT

    Does anyone know how I can get the system/git to perform the conversion to EBCDIC before I get the output ?

    Regards,
    Gary

    Just WOW on the activity and good replies here :slight_smile:

    Still a bit ‘untangible’ as to where it fails and why. I have no different results with bash 4.2 or 4.3. So for now the iconv-fix is making it work…

    If you want a ‘working’ experience too, I’ve git-gisted my solution here : https://gist.github.com/wizardofzos/c588e203aa14b80576712d664406df11

    Sergey Rezepin
    Rocketeer
    Mar 6, 2018 3:06 AM UTC

    I have written a REXX exec to inface to GIT.

    Specifically I use BPXWUNIX to issue my commands. The issue I have is the output from the command is always in ASCII (ISO-8859-1). Forcing me the perform a conversion before I can read the results.

    This doesn’t happen if I issue the command in OMVS.

    I’ve tried using BPXWUNIX using redirection

    eg    x=BPXWUNIX('git status >output.txt',,,,,1)  
    

    and coding the stdout in the function call

    eg   x=BPXWUNIX('git status',,'output.',,,1) 
    

    I have my profile setup with

    export _CEE_RUNOPTS="FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"
    export _BPXK_AUTOCVT=ON
    export _TAG_REDIR_ERR=TXT
    export _TAG_REDIR_IN=TXT
    export _TAG_REDIR_OUT=TXT

    Does anyone know how I can get the system/git to perform the conversion to EBCDIC before I get the output ?

    Regards,
    Gary

    The internal issue is opened for this case.

    Mar 23, 2018 10:47 AM UTC

    The internal issue is opened for this case.

    A colleague of mine had a very good idea. He said: Check what curl and git do to STDOUT and STDERR in terms of tagging.

    I did and found that curl changes tagging to

    STDOUT: 1047 8000
    STDERR: 1047 8000

    This is the reason that git produces readable output when calling curl first.

    When calling git without prior invocation of curl no tagging takes place that is before and after calling git we have:

    STDOUT: 0000 0000
    STDERR: 0000 0000

    Mar 25, 2018 8:14 PM UTC

    A colleague of mine had a very good idea. He said: Check what curl and git do to STDOUT and STDERR in terms of tagging.

    I did and found that curl changes tagging to

    STDOUT: 1047 8000
    STDERR: 1047 8000

    This is the reason that git produces readable output when calling curl first.

    When calling git without prior invocation of curl no tagging takes place that is before and after calling git we have:

    STDOUT: 0000 0000
    STDERR: 0000 0000

    Excellent Manfred.

    Is there anything I can do to change the tagging for GIT or is this an internal thing that Rocket has to do to the GIT product internally?

    Regards,
    Gary