ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

STRPCCMD and a PC batch file

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

  • STRPCCMD and a PC batch file

    I'm trying to execute a batch file in a folder on my C drive fom a CL program on our iSeries.

    The batch file contains this statement: -s:download.txt which is the text file that contains my FTP commands.

    The path to the .bat file is C:/crap/latest/download.bat and is what is contained in the passed parameter &DATA in the code example below.

    my code is:
    Code:
    ** Beginning of data ***********************
    PGM        PARM(&DATA)                      
                                                
    DCL        VAR(&DATA ) TYPE(*CHAR) LEN(  70)
                                                
    STRPCO     PCTA(*NO)                        
    MONMSG     MSGID(IWS4010)                   
                                                
    STRPCCMD   PCCMD(&DATA) PAUSE(*YES)         
    GOTO       CMDLBL(END)                      
                                                
    ENDPGM
    I'm getting a message stating that there was an error opening the download.txt file. That's it, no other explanation or information.

    Any ideas what could be causing this error?

    Red.
    Everyday's a school day, what grade are you in?

  • #2
    Re: STRPCCMD and a PC batch file

    Just a guess that it doesn't have the right path to that file so can't find it.

    Comment


    • #3
      Re: STRPCCMD and a PC batch file

      Originally posted by redvan
      I'm getting a message stating...
      Getting a message where? How does it show up? Is it message in the server session or a PC command window?

      The example is apparently a trimmed down version of your actual program since it can't compile. (There is no label "END" for the GOTO.) Is any other part modifying &DATA?

      Finally, since &DATA is an incoming parm, how are you calling your program? What does an actual failing CALL statement look like?
      Tom

      There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

      Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

      Comment


      • #4
        Re: STRPCCMD and a PC batch file

        Tom,
        Yes, the sample code I supplied is a trimmed down version of what I actullay use. I trimmed it down because I was trying so many different approaches that I didn't want to confuse the issue with commented code so I copied the source, trimmed it and posted it and I missed the 'GOTO END' in my clenaup.

        As for the message I discovered;
        My Download.txt file is a FTP script file with the basic FTP commands in it; OPEN, LCD, CD, MGET and QUIT.
        The batch file Download.bat has the following: 'ftp -Sownload.txt>ftpout.txt' plus some RENAME lines.

        Well, the command window that appears when running was showing something about not being able to rename the objects so I scrolled up in the window and at the top is where I found the message. (trying to attach a document with a scrreen print of the command window...)

        As for the failing Call statement;
        The program doesn't fail. The request seems to process and then in the command window, I get the message 'Press any key to continue'.

        Red
        Everyday's a school day, what grade are you in?

        Comment


        • #5
          Re: STRPCCMD and a PC batch file

          Here's the command window...
          Attached Files
          Everyday's a school day, what grade are you in?

          Comment


          • #6
            Re: STRPCCMD and a PC batch file

            Where is Download.txt located, it looks like it is not where it can be found. Try specifying the entire path to it or do a CD to the directory where it resides before using it.

            Comment


            • #7
              Re: STRPCCMD and a PC batch file

              Scott,
              C:/CRAP/CLNMBR/DOWNLOAD.BAT - This is the string passed to the above code in &DATA.

              The Download.txt file is in C:/CRAP/CLNMBR
              Everyday's a school day, what grade are you in?

              Comment


              • #8
                Re: STRPCCMD and a PC batch file

                That part is correct because it is running your batch file - it is getting the error finding the script file Download.TXT

                Comment


                • #9
                  Re: STRPCCMD and a PC batch file

                  Scott,
                  I do not understand.... The .TXT file is in the same folder as the .BAT file so how can the batch file not find it?

                  Red.
                  Everyday's a school day, what grade are you in?

                  Comment


                  • #10
                    Re: STRPCCMD and a PC batch file

                    Here's the file locations....
                    Attached Files
                    Everyday's a school day, what grade are you in?

                    Comment


                    • #11
                      Re: STRPCCMD and a PC batch file

                      If you look at the command window you posted earlier, the current directory is not where the batch file is located. That is why it cannot find it.

                      Comment


                      • #12
                        Re: STRPCCMD and a PC batch file

                        Scott,
                        Do I need to add a CD to the begining of the string?

                        (I'm fairly new to this so please don't asume I know anything. I've only done something similar twice and that was easy and worked first time, every time. This is far more complicated than those attempts.)

                        Red
                        Everyday's a school day, what grade are you in?

                        Comment


                        • #13
                          Re: STRPCCMD and a PC batch file

                          You need to add another command to the beginning of your batch file:

                          CD c:\Crap\CLNMBR

                          This will change the directory to where your files are located. You can test the syntax in the 'Command Prompt' window to make sure it is correct.

                          Comment


                          • #14
                            Re: STRPCCMD and a PC batch file

                            Let me clarify how this works and maybe that'll shed some light on all this.

                            I have a program that displays a screen. On the screen are entries and for each entry there are options for run, path and delete.

                            When Run is selected, the CL code posted above is called.
                            When Path is selected, a window opens where the path can be defined. This is what is passed to the CL in &DATA when Run is selected.

                            Currently the path for the entry I'm testing is C:/CRAP/CLNMBR/DOWNLOAD.BAT

                            So, do I need to change this path eventhough this is where the .bat and .txt files reside or do I need to add CD before the string or do I need to do something else?

                            Red.
                            Everyday's a school day, what grade are you in?

                            Comment


                            • #15
                              Re: STRPCCMD and a PC batch file

                              The CD is command Change Directory that would go in the beginning of the batch file. Will the person who creates the batch file Download.bat know what the path will be and can include the CD command at the beginning of it? If not, you will need a method to edit the .bat file which I am not sure how to do. What is the overall goal you are trying to accomplish, maybe there is a better approach than calling STRPCCMD to call a ftp script on the PC. Depending on what you are doing you might be able to do the ftp on the i and put the files on a network share available to the PC.

                              Comment

                              Working...
                              X