ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Running a *.bat program from RPG

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

  • Running a *.bat program from RPG

    Does anyone know how to map to a network drive and run a test.bat program inside of an RPG program? The test.bat is on my network drive and I have to schedule that test.bat to run each night at 6:00PM. I know I can schedule my RPG program to run at 6:00PM using the wrkjobscde.

    Thanks,

    David C

  • #2
    Re: Running a *.bat program from RPG

    David,

    (you could get this to work from Batch)
    Try using the RUNRMTCMD

    or

    (interactive)

    STRPCO

    STRPCCMD 'E:\somefile.bat'
    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: Running a *.bat program from RPG

      I am trying a RUNRMTCMD CMD but each time I get this
      A remote host refused an attempted connect operation.
      Command did not complete successfully.

      I know the IP address is correct and the user and password is working. Any suggestions?

      Thanks,

      David C

      Comment


      • #4
        Re: Running a *.bat program from RPG

        Here is some info on RUNRMTCMD

        Code:
        *A:*When you specify the user ID and password on the RUNRMTCMD command
        that's used to initiate the PC job from AS/400, you must enclose both
        the user name and password in single quotes. In addition, unlike the
        AS/400, the PC's passwords are case sensitive, so you must be careful to
        correctly match all the cases in both the user ID and password. The
        following example shows how to specify the user ID and password
        parameters in a RUNRMTCMD command:
        
        RUNRMTCMD                  +
         CMD(c:\temp\mybatch.bat) +
         RMTLOCNAME(MyPC *IP)     +
         RMTUSER('myUSER')        +
         RMTPWD('myPASS')


        Code:
        *Q: Iâ??m having trouble using the RUNRMTCMD command to execute commands on
         my PC. When I attempt to execute RUNRMTCMD, I get the message "CPF91CC: 
        Command did not complete successfully. A remote host refused an attempted 
        connect operation." Iâ??m using V4R2 with TCP/IP and Windows 95. Can you help?*
        
        
        *A:* To use RUNRMTCMD, you must make sure the Client Access Incoming Remote
        Command function is enabled on your PC. To enable the function, access Client 
        Access Properties and then click the Incoming Remote Command tab (*Figure 3* 
        </ArtArchiveImages/figure.cfm?Figure=PreDec99/1999/November/1199124-
        3.gif>). If you want Incoming Remote Command to start whenever your PC starts, 
        select the option to do so. You can also start the function manually by running the
         CWBRXD.EXE program (found in the Client Access directory).
        
        If youâ??re running Windows 95/98, you also need to add the names and 
        passwords of users who are authorized to run commands. Click the tabâ??s Add 
        button to do this. Enter the incoming system name, user ID, and password of 
        each person permitted to run PC commands remotely. Note that you can use an 
        asterisk (*) wildcard for the systems and/or users that are allowed to run 
        commands on this system.
        
        
        If youâ??re running Windows NT, anyone who can sign on to the system (as defined 
        by Windows NT security) can run commands theyâ??re authorized to run.

        problems with XP SP2 installed
        Code:
        A: Microsoft documents several ways administrators can work around problems 
        created by Windows firewall restrictions. Some of these ways, including the use of 
        a group policy, are beyond the scope of this article. But here's one approach that 
        should work on all PCs running Windows XP with SP2 installed. 
        
        
        Each of the iSeries Access for Windows functions that requires incoming 
        connections listens on specific ports on the PC. Therefore, to work around 
        problems, configure the Windows firewall to allow network traffic through those 
        ports or to the function programs themselves. Such allowances are called 
        Windows firewall exceptions. The following instructions describe how to configure 
        Windows firewall exceptions from a command line. If you're using a different 
        firewall on your PC, the port numbers and program names will be the same, so
        the configuration steps will likely be similar. If you wish to use a graphical user
         interface to configure Windows firewall exceptions, open the Security Center 
        option from the Control Panel, and run the Windows Firewall applet. 
        (Note: The user creating Windows firewall exceptions must have 
        Adminis-trator rights on the PC.) 
        
        
        
        Incoming Remote Command: You must configure the firewall product to allow 
        incoming connections either to the TCP exec server port (which by default is port 
        12) or to cwbrxd.exe (the program that provides the Incoming Remote Command 
        function). Be aware that any remote computer running the rexec client may 
        attempt to connect to this program once the exception is enabled. The simplest 
        way to get Incoming Remote Command to work is to allow connections to 
        cwbrxd.exe by running the following command from a command line (note: type
         this and the following commands on one line): 
        
        netsh firewall add allowedprogram "%windir%\cwbrxd.exe" 
        
        "iSeries Access Incoming Remote Command server (cwbrxd)"
        
        Operations Console: For local connections, use UDP port 67 and TCP port 2112. 
        Port 67 is the port used for the "bootp" service, which is needed to connect for 
        the first time. Port 2112 is used for communications within the PC, so it must 
        accept connection requests from the loopback address (127.0.0.1). For remote
        connections into a local console, the listening port could be anywhere in the range
        of 1025 to 5000. For that reason, you should set up an application exception pcon.exe instead of specifying an individual port. This same application 
        exception will handle ports 67 and 2112. To create this firewall exception, run the
         following command from a command line: 
        
        netsh firewall add allowedprogram "<INSTALL>\cwbopcon.exe" 
        
        "iSeries Access Operations Console (cwbopcon)"
        
        Note that you should use the actual install path for iSeries Access for Windows on 
        the PC in place of <INSTALL>. By default, this path is C:\Program Files\IBM\Client
         Access. 
        
        Management Central: Due to unique networking requirements for this function, 
        it's recommended that you read the information at the following link before configuring a firewall exception for Management Central functions. If you're at 
        V5R3, go to 
        publib.boulder.ibm.com/infocenter/iseries/v5r3/ic2924/info/experience/mcfirewall.pdf. 
        If you're running V5R2, visit publib.boulder.ibm.com/iseries/v5r2/ic2924/info/experience/mcfirewall.pdf. 
        
        In most cases, however, running the following command should suffice to create 
        the correct exception: 
        
        netsh firewall add allowedprogram "<INSTALL>\cwbunnav.exe" 
        
        "iSeries Navigator and Management Central (cwbunnav)"
        
        Once again, replace <INSTALL> with the actual iSeries Access for Windows install 
        path. As mentioned earlier, the default is C:\Program Files\IBM\Client Access.
        
        For all the netsh command invocations above, an "OK" message should appear to 
        indicate that the command was successful. If the message indicates that the file 
        was not found, then likely that component of iSeries Access isn't installed, or you 
        mistyped the program path or file name. If the component isn't installed, then you
         do not need an exception. If you install the component later, make sure that you
         run the netsh command afterward or that you use the Windows firewall graphical 
        user interface to create the appropriate exception.


        jamie
        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


        • #5
          Re: Running a *.bat program from RPG

          just found this somewhere also..

          Its an IBM supplied new version of runrmtcmd???

          Let me know
          Jamie


          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

          Working...
          X