ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Using RUNRMTCMD to run a .bat job on my PC

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

  • Using RUNRMTCMD to run a .bat job on my PC

    I can run a .bat file from my PC using CL Program:

    Code:
    PGM                                                      
                                                             
    DCL        VAR(&IPADDR) TYPE(*CHAR) LEN(16)              
                                                             
    CALL       PGM(CAIPADD) PARM(&IPADDR)                    
                                                             
    RUNRMTCMD  +                                             
                 CMD('C:\Users\knop\Desktop\fueltaxmapper.ba+
                 t') RMTLOCNAME(&IPADDR *IP) +               
                 RMTUSER('xxxx') RMTPWD('xxxxxxxxx')         
                                                             
    ENDPGM
    The program CAIPADD retrieves the ip address of my PC. The .bat file tries to do a CD to
    a mapped drive. When I run the CL I get this in the spool file generated by RUNRMTCMD:

    PHP Code:
     C:\Windows\system32>cd z:\                                                        
    The system cannot find the drive specified.                                       
    C:\Windows\system32>copy z:\FuelTaxExportNewConfig.xml C:\Program Files (x86)\Xa  
    ta\translator\cfg                                                                 
    The system cannot find the drive specified
    .                                       
    C:\Windows\system32>ren FueltaxExportNewConfig.xml FuelTaxExport2Mapper_Config.x  
    ml 
    The system cannot find the file specified.


    Anyone have any thoughts as to why I can get to the C:\ Drive but not to mapped drive Z:\ ?

    Thanks.

  • #2
    Re: Using RUNRMTCMD to run a .bat job on my PC

    When you run a command via RUNRMTCMD, it behaves as a separate session.

    This is hard to explain... lessee... well, you know that on IBM i, you might have one 5250 session open, and you might open a second one by launch a separate 5250 session... then you have to sign in to that 2nd session, and type separate commands in that separate session, etc... it's a whole separate job. That separate job might have different things on the display, different library list, etc.

    Windows isn't exactly like IBM i. But it has a similar concept... a separate sign-in session, with separate settings, etc.

    And that's what happens with RUNRMTCMD, you get a separate session. It could (potentially) be signed in with a different userid/password, and can have different settings. Much like opening a 2nd 5250 window would be on IBM i.

    My guess is that the Z: drive is not mapped in the RUNRMTCMD session, but it is mapped in the original one, and this is why you get the "cannot find the drive specified" error.

    I would suggest doing things by UNC path (instead of using a drive letter) if at all possible.

    Comment


    • #3
      Re: Using RUNRMTCMD to run a .bat job on my PC

      I can run the ftp on the PC just fine. I've changed it up just a little.

      PHP Code:
      Microsoft Windows [Version 6.1.7601]
      Copyright (c2009 Microsoft Corporation.  All rights reserved.

      C:\Users\knop>cd C:\Program Files (x86)\Xata\translator\cfg

      C
      :\Program Files (x86)\Xata\translator\cfg>ftp 172.19.100.5
      Connected to 172.19.100.5
      .
      220-QTCP at MYAS400.COM.
      220 Connection will close if idle more than 5 minutes.
      User (172.19.100.5none)): knop
      331 Enter password
      .
      Password:
      230 KNOP logged on.
      ftpcd /home/xatatripexp
      250
      -NAMEFMT set to 1.
      250 
      "/home/xatatripexp" is current directory.
      ftpget fueltaxexportnewconfig.xml
      200 PORT subcommand request successful
      .
      150 Retrieving file /home/xatatripexp/fueltaxexportnewconfig.xml
      226 File transfer completed successfully
      .
      ftp1917 bytes received in 0.00Seconds 1917000.00Kbytes/sec.
      ftp
      This works great!

      My .bat file looks like this:
      PHP Code:
      cd cd C:\Program Files (x86)\Xata\translator\cfg
      ftp 
      -s:fueltaxmapper.ftp 172.19.100.5
      rename FueltaxExportNewConfig
      .xml FuelTaxExport2Mapper_Config.xml 
      The fueltaxmapper.ftp file looks like this:
      PHP Code:
      KNOP
      PASSWORD
      quote site namefmt 1
      cd 
      /home/xatatripexp
      Get FuelTaxExportNewConfig
      .xml
      quote site namefmt 0
      Quit 
      Now, when I try to make this happen via runrmtcmd, this happens.

      (this is in the QSYSPRT spool file after I run my CLLE program w/RUNRMTCMD)

      'C:\Program' is not recognized as an internal or external command,
      operable program or batch file.
      PHP Code:
      My CLLE pgm:
      (
      CAIPADD grabs the ip address of my PC)

      PGM                                                      
                                                               
      DCL        
      VAR(&IPADDRTYPE(*CHARLEN(16)              
                                                               
      CALL       PGM(CAIPADDPARM(&IPADDR)                    
                                                               
      RUNRMTCMD  CMD('C:\Program Files +                       
                   (x86)\Xata\translator\cfg\fueltaxmapper.bat+
                   '
      RMTLOCNAME(&IPADDR *IP) +                
                   
      RMTUSER('knop'RMTPWD('password')         
                                                               
      ENDPGM 
      Help! I can't figure out why this isn't working.

      Thanks,

      Phil

      Comment


      • #4
        Re: Using RUNRMTCMD to run a .bat job on my PC

        A blank is normally treated as a parameter separator in MS-DOS. So the blank in "Program Files" is making the DOS prompt think that the command is two separate parameters.

        Try enclosing the string in double-quotes, so that the blank isn't seen as a parameter separator.

        Comment


        • #5
          Re: Using RUNRMTCMD to run a .bat job on my PC

          Thanks Scott.

          OK, I changed it and got the following:

          C:\Windows\system32>cd cd C:\Program Files (x86)\Xata\translator\cfg
          The filename, directory name, or volume label syntax is incorrect.
          C:\Windows\system32>ftp -s:fueltaxmapper.ftp 172.19.100.5
          Error opening script file fueltaxmapper.ftp.

          I understand I might need to use the 'DOS' naming "dosna~1.nam" for 'Program Files (x86)' and 'translator'.

          I can't figure out what the 'Program Files (x86)' should be called. In Windows 7 there's 'Program Files' and
          'Program Files (x86)'. I assume the 'Program Files' would be 'Progr~1' but what about the 'Program Files (x86)'?

          Or am I just way off?

          I appreciate you taking the time to help.

          Phil

          Comment


          • #6
            Re: Using RUNRMTCMD to run a .bat job on my PC

            Well, if the name is quoted properly, you shouldn't need to use the DOS short names. You just need to quote it properly so the blank isn't treated as a special value.

            But, if you do want to use the short names, you can do (from a DOS prompt) dir /X to see the short names.

            Just, please be aware that the short names may vary from installation to installation. It might be PROGRA~2 on one box, and PROGRA~3 on another. It depends on what filenames were there prior to creating the "Program Files (x86)" directory. Thus, my recommendation is to figure out how to quote or escape the string properly so blanks won't be given a special meaning.

            Comment


            • #7
              Re: Using RUNRMTCMD to run a .bat job on my PC

              This is the code I set up:
              PHP Code:
              RUNRMTCMD  CMD('"C:\Program Files (x86)\Xata\translator\cfg\fueltaxmapper.bat"'RMTLOCNAME(&IPADDR *IP) +                 
                           
              RMTUSER('knop'RMTPWD('password'
              The runrmtcmd puts the single quotes around the CMD part. Should I remove them?

              Also, I running Windows 7, 64-bit if that matters.

              Thanks,

              Phil Knox

              Comment


              • #8
                Re: Using RUNRMTCMD to run a .bat job on my PC

                Sorry Scott. It worked. I had two 'cd' at the beginning of the batch file.

                Thanks for your help!

                Comment


                • #9
                  Re: Using RUNRMTCMD to run a .bat job on my PC

                  Using RUNRMTCMD in a CLLE program the .bat file I'm using calls a process on my PC. The process seems to be running but I can't tell
                  because the .bat file doesn't open a dos window on my PC. Also, the process is supposed to output to a mapped drive (a shared folder on the IFS) but
                  nothing is happening as far as the file being updated there.

                  I could use some help with this. Anyone do this kind of processing?

                  I can run the process from the PC no sweat. but run from the iSeries nada.

                  Thanks,

                  Phil Knox

                  Comment


                  • #10
                    Re: Using RUNRMTCMD to run a .bat job on my PC

                    I've done this sort of thing before, though I must admit, it's been awhile.

                    What sort of help do you need?

                    Comment


                    • #11
                      Re: Using RUNRMTCMD to run a .bat job on my PC

                      What's keeping the runrmtcmd job from finding mapped drives?

                      Comment


                      • #12
                        Re: Using RUNRMTCMD to run a .bat job on my PC

                        Could it be the issue I described in post #2, above?

                        Comment


                        • #13
                          Re: Using RUNRMTCMD to run a .bat job on my PC

                          I had to change the process. I gave up.
                          Thanks for your help.

                          One last Q. If I put a CHGMSGQ MSGQ(&USRNAM) DLVRY(*BREAK) SEV(0) in my cl
                          what sets it back to normal?

                          Thanks,

                          Phil Knox

                          Comment


                          • #14
                            Re: Using RUNRMTCMD to run a .bat job on my PC

                            Chgmsgq msgq(&usrnam) dlvry(*notify) sev(0)
                            I'm not anti-social, I just don't like people -Tommy Holden

                            Comment


                            • #15
                              Re: Using RUNRMTCMD to run a .bat job on my PC

                              Thanks Tom.

                              Thanks Scott, for everything.

                              Phil Knox

                              Comment

                              Working...
                              X