ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Create Folder and Subfolder in IFS at the same time

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

  • Create Folder and Subfolder in IFS at the same time

    Hi

    i'm try to run the command MKDIR DIR(MYFLR/MYSUBFLR) , but if MYFLR don't exist i receive error; so i would i need fisrt create MYFLR and MYSUBFLR. Now as i have a variable &MYVAR, that could contain "MYFLR" or "MYFLR/MYSUBFLR" or "MYFLR/MYSUBFLR/MYXXXFLR" ecc. that i use in the cmd MKDIR DIR(&MYVAR) is there any utility command that divides the &MYVAR in fields MYFLR, MYSUBFLR etc etc ..
    Any suggestion will appreciated

    Thanks in advance

  • #2
    Re: Create Folder and Subfolder in IFS at the same time

    I got this:
    QSH CMD('mkdir -p /home/PDF/username/2010/03/21/')

    This will create any directories it needs along the way, eventually
    Ending with the 21 directory. It will also *not* error out if the
    complete path already exists.
    here:


    Best of luck
    GLS
    The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

    Comment


    • #3
      Re: Create Folder and Subfolder in IFS at the same time

      Now thats a hot tip, thanks man.
      Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

      Comment


      • #4
        Re: Create Folder and Subfolder in IFS at the same time

        It looks like I'm spreading bad info. This was in other parts of the same post:

        Not so in my case. I got an error if the directory tree already exists.

        Dang! You're right! I ran this out untested because I *trusted* that QSH
        followed KornShell standard, as it almost always does. But,
        disappointingly, not in this case.
        My apologies>
        GLS
        Last edited by GLS400; May 15, 2015, 01:40 PM.
        The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

        Comment


        • #5
          Re: Create Folder and Subfolder in IFS at the same time

          As long as you're using QShell, why not check to see if the directory is there, and only try to create it if it's not there?

          Code:
          QSH CMD('test -d /home/PDF/username/2010/03/21 || mkdir -p /home/PDF/username/2010/03/21/')
          To avoid duplicating things, I would set the directory path as an environment variable
          Code:
          PGM
          
             ADDENVVAR ENVVAR(NEWDIR) VALUE('/home/PDF/username/2010/03/21') REPLACE(*YES)
             QSH CMD('test -d $NEWDIR || mkdir -p $NEWDIR')
          
          ENDPGM
          The VALUE() parameter on ADDENVVAR could also take a CL variable, too, allowing you to get directory names you calculate in your CL program, etc.

          Comment


          • #6
            Re: Create Folder and Subfolder in IFS at the same time

            Hi Scott

            after QSH CMD('mkdir -p /home/PDF/username/2010/03/21/') i have insert the "MONMSG MSGID(CPF0000) ", do you see side effects and so i suggest to you use your example ?

            Thanks

            Comment


            • #7
              Re: Create Folder and Subfolder in IFS at the same time

              MONMSG CPF0000??? That makes no sense, QSH doesn't send CPF messages!

              Comment

              Working...
              X