ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

qshell jar question

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

  • qshell jar question

    I am using qshell jar to create a zip file on IFS which are emailed to users.


    STRQSH CMD('jar -cfM /home/fileA.zip +
    /home/fileB.csv')

    It works fine, but creates a "nested" directory structure forcing the user to click through several directories to access their data.

    Can anyone propose a way to avoid this clickthrough?

    more on jar:

  • #2
    Re: qshell jar question

    I cant read the link I thinks it's in portuguese.

    cant you just email the zip file as an attachment ?
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: qshell jar question

      Actually I think it's Spanish, but you get the idea.

      The file is zipped with .zip using jar utility, but it arrives nested in multiple subdirectories replicating the file's original location.

      This may be a nice feature for installing java applications, but it is annoying for end users who have to click through several directories to get their data.

      Comment


      • #4
        Re: qshell jar question

        It is an essential function of the jar utility that it keeps the directory structure. The primary reason for a jar is to package up java .class files. These have to live in a directory structure that reflects the package. If I write a class that is in the com.code400.app package then that class will have to live in a folder called app that is a sub-folder of code400 that is a sub folder of com. If the class was anywhere else then the JVM would not be able to find it.

        Having said that...

        If you set your current directory to the one containing the files you want to jar, then there will be no directory structure for it to replicate.

        Try the following:
        PHP Code:
        CD DIR('/home')
        STRQSH CMD('jar -cfM fileA.zip fileB.csv'
        I don't know what effect naming your jar as a zip would have. A jar is different to a zip is it not? You can't convert an image from png to jpeg just be changing the file extension and I would have thought the same would apply here.
        Ben

        Comment


        • #5
          Re: qshell jar question

          Another option would be to install the InfoZip software that runs under PASE. Scott Klement wrote a couple of articles about it for the iSeries Network magazine. Here's a link to a recent forum thread about it:



          Terry

          Comment


          • #6
            Re: qshell jar question

            A jar file is nothing more than a renamed zip file Just for future reference, if you would find yourself on a system that has the ability to create a jar file, but for some reason no zipping utility you can create it as a jar. I haven't tested this next part, but I think you can take it into an unzipping utility and unzip it, you just have to go through the jar's directory structure first to get to the files to extract... I believe this to be true...someone may one to correct me if I'm wrong...I was just reading something about this yesterday and I can't remember where I found it...
            Your future President
            Bryce

            ---------------------------------------------
            http://www.bravobryce.com

            Comment


            • #7
              Re: qshell jar question

              Ok, looked into it a bit more. A jar is an archive file as is a zip but they are not exactly the same. A jar file complies with the zip standard so it should be possible to rename a jar as a zip and open it with an unzip tool. However, not all zip files are valid jars so you can't guarantee it will work going the other way.

              To avoid the directory structure you should set the current directory as per my previous post. This will build the jar in that directory also. I found the easiest way to build it in a different directory was to build it first and then move it. You can accomplish this using the "mv" qshell command.

              Ben

              Comment


              • #8
                Re: qshell jar question

                Hey Ben,

                Thanks for clearing that up
                Your future President
                Bryce

                ---------------------------------------------
                http://www.bravobryce.com

                Comment


                • #9
                  Re: qshell jar question

                  Bent's "CD" suggestion works for me.
                  A jar extract with a .zip extention seem to have behave just like a zip file.

                  Here is my recipe if you want to try this at your place.
                  PHP Code:
                   /* copy from PF to CSV file on IFS - (this can be opened directly by most spreadsheet programs) */                       
                   
                  CPYTOIMPF  FROMFILE(MyFile *FIRST) +                        
                                
                  TOSTMF('/home/file1.csv'MBROPT(*ADD) +       
                                
                  STMFCODPAG(*STDASCIIRCDDLM(*CRLF) +          
                                
                  DTAFMT(*DLMSTRDLM('"'FLDDLM(';')           
                                                                               
                   
                  /* Set default IFS directory */                             
                   
                  CD DIR('/home')                                             
                                                                               
                   
                  /* Compress file with QShell jar utility to .zip file */    
                   
                  STRQSH     CMD('jar -cfM  file2.zip  file1.csv')            
                                                                               
                   
                  /* Send to user(s) using Gumbo SendSpollMail Utility */     
                   
                  SNDSPLMAIL FILE(QPSUPRTFJOB(*) TRANSFORM(*TXT) +          
                                
                  TOSMTPNAME((user@company.com)) +       
                                
                  SUBJECT(SUBJECTMSG(MESSAGE) +                
                                
                  PCFILE('attach.txt'EXTENSION(TXT) +          
                                
                  INCOBJ(('/home/file2.zip' *ATTACH) +           
                                (
                  '/home/file1.csv')) 

                  Comment

                  Working...
                  X