ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Running PASE command 7z from QSH

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Running PASE command 7z from QSH

    Hi,
    I need to unzip/zip a bunch of files in an IFS folder from an RPG ILE program.
    As the format for both initial and final zipped files is RAR I installed 7z utility from Scott Klement repository.
    Everything works fine when running the commands from QP2TERM, but I can't make the same commands working from QSHELL, which I could call passing both the change directory command and the zip/unzip request. I always get this error:

    > 7z a test3.rar *.*
    /usr/bin/7z: 001-0019 Errore rilevato durante la ricerca del comando ÂÑ. Questo percorso o indirizzario non esiste.
    /usr/bin/7z: 001-0014 Comando } Î/Ê?øÈø :Ñø%ÑÂ Î/Ê?øÈø :Ñø%ÑÂø :Ñø : non trovato.
    which more or less sounds like "Error while searching the command. The path or the directory doesn't exist"; also, I can't really understand why there are so many unconverted characters.

    The PATH environment variable returns:
    > echo $PATH
    /usr/bin:.:/QOpenSys/usr/bin
    and the soft links to 7z command exists in both the path directories.


    Given that IBM iOS version is V7R2 I thought QSH can run PASE commands without problems, but obviously my assumption is wrong.

    Is there something I miss to make 7z running from QSH?

    Thank you very much


  • #2
    You don't say how you are currently trying to invoke the QSHELL version but ...

    Scott's UNIXCMD can run jobs for you in both environments so maybe using that would resolve your issue?

    Comment


    • #3
      The 7z file that is in my download package is a very simple shell script, it looks like this:
      Code:
      #! /bin/sh
      LIBPATH=/var/opt/p7zip/lib /var/opt/p7zip/lib/p7zip/7z "$@"
      For some reason this is working for you in PASE but not in QShell? Is it possible that the CCSID of this file is set incorrectly? Use WRKLNK '/var/opt/p7zip/bin/*' and take option 8 next to the '7z' script. What CCSID is it set to? It should be 819.

      Then take option 5 next to it, and use F10 (display hex) to verify that the characters are indeed in the iso-8859-1 encoding. i.e. they should have ASCII hex values, not EBCDIC ones.

      Also make sure that the paths listed in this file do indeed exist.

      Comment


      • #4
        So,

        @JonBoy
        I start the QSHELL invoking QSH command. The next step should be a QCMDEXEC from my program with some code like
        Code:
        QSH CMD('cd /mydir;7z e /mydir/File.rar')
        in it.

        @Scott Klement
        Firstly, I checked the script:
        CCSID for /var/opt/p7zip/bin/7z script is set to 280 (Italian), but it seems to me that the content is ASCII:
        Code:
        2321202F 62696E2F 73680A                       #! /bin/sh            
        4C494250 [B]41[/B]54483D 2F76[B]61[/B]72 2F6F7074 2F70377A   LIBPATH=/var/opt/p7z
        as capitol A is hex(41) and lowercase a is hex(61) as it should be.

        Secondly, both paths exist in IFS.

        Can I try to change the CCSID of the script?

        Comment


        • #5
          I've digged more into the issue and I realized that all the objects I installed are owned by my user profile, like these:
          Code:
          cd /usr/bin                                                                                                          
          $                                                                                                                    
          ls -l                                                                                                                
          total: 620 kilobytes                                                                                                
          lrwxrwxrwx  1 STOPPA  0                    21 Dec  9 17:52 7z -> /var/opt/p7zip/bin/7z                              
          lrwxrwxrwx  1 STOPPA  0                    22 Dec  9 17:53 7za -> /var/opt/p7zip/bin/7za                            
          lrwxrwxrwx  1 QSYS    0                    29 Oct 26  2017 ajar -> /QSYS.LIB/QSHELL.LIB/AJAR.PGM                    
          lrwxrwxrwx  1 QSYS    0                    39 Oct 26  2017 appletviewer -> /QIBM/ProdData/Java400/bin/appletviewer  
          lrwxrwxrwx  1 QSYS    0                    30 Oct 26  2017 apt -> /QIBM/ProdData/Java400/bin/apt                    
          lrwxrwxr-x  1 QSYS    0                    24 Oct 26  2017 armsrv -> /QSYS.LIB/QPMWARTSRV.PGM                        
          lrwxrwxr-x  1 QSYS    0                    24 Oct 26  2017 armsrvconv -> /QSYS.LIB/QPMWARTCNV.PGM
          May this be the problem? I mean, should the commands that run in QSHELL be owned by a different user profile, like QPGMR, instead?

          Comment


          • #6
            Running PASE from native QSHELL works: so this command
            Code:
            QSH CMD('/QOpenSys/usr/bin/sh -c "cd /mydir; 7z e test6.rar"')
            works fine.
            I know it's just a workaround but I found a way, at least.

            Comment


            • #7
              The reason it works from PASE is because PASE doesn't know about CCSIDs. It only understands ASCII, so it doesn't matter that your script is marked as Italian EBCDIC, it doesn't even look at the CCSID. QShell, on the other hand, understands all different CCSIDs, so it sees that the data is Italian EBCDIC and tries to treat it as such. Since the data is NOT Italian EBCDIC (as I said earlier, it is iso-8859-1) it fails.

              Set the CCSID properly and it'll work.

              Code:
              CHGATR OBJ('/var/opt/p7zip/bin/7z') ATR(*CCSID) VALUE(819)
              Do the same for anything else that's incorrectly marked as CCSID 280. (You might also look into what caused it to mark these as 280, as they are not marked that way on my system that you restored the files from.)

              Comment


              • #8
                Hi, Scott, thank you very much!
                Now it works.

                Comment

                Working...
                X