ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Copy file to local pc from IFS

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

  • Copy file to local pc from IFS

    Hi,

    Anyone have any idea to copy a file from IFS to local c:\ regardless of knowing the windows IP , shared drive.

    Thanks,

    Mini

  • #2
    Re: Copy file to local pc from IFS

    FTP from the PC to the system use namefmt 1 and get???
    I'm not anti-social, I just don't like people -Tommy Holden

    Comment


    • #3
      Re: Copy file to local pc from IFS

      Originally posted by tomholden View Post
      FTP from the PC to the system use namefmt 1 and get???
      Thanks Tom, but its a process which needs to run on AS400 and on no. of users taking session of AS400 server on different location.

      Comment


      • #4
        Re: Copy file to local pc from IFS

        Originally posted by minishoppe
        Hi,

        Anyone have any idea to copy a file from IFS to local c:\ regardless of knowing the windows IP , shared drive.

        Thanks,

        Mini
        Can you clarify what your trying to do. Your going to need to tell the 400 where your going to send the file and then how it should send it..

        Comment


        • #5
          Re: Copy file to local pc from IFS

          Originally posted by DAG0000 View Post
          Can you clarify what your trying to do. Your going to need to tell the 400 where your going to send the file and then how it should send it..
          Dear DAG,

          As a requirement there will be a report in the form PDF will create on IFS and on pressing of function key it will be downloaded to windows and open it in the front of user.

          In this case I need to open a ftp session on windows that will get the PDF file from IFS and open it.

          Let me know if anything unclear to you.

          Thanks

          Comment


          • #6
            Re: Copy file to local pc from IFS

            I have a CGIDEV2 program (with lots of help from Scott Klement examples) that streams PDF files stored in our IFS to a browser. You could probably STRPCCMD with parms to a program like this which would open up a browser window to display the PDF. Depending on your HTTP configuration you may even be able to open Adobe itself.

            For that matter ... you may be able to STRPCCMD and open that Adobe file directly, but your user would need to have a mapped drive to the IFS and be logged in or login during the process.
            Your friends list is empty!

            Comment


            • #7
              Re: Copy file to local pc from IFS

              Originally posted by minishoppe View Post
              As a requirement there will be a report in the form PDF will create on IFS and on pressing of function key it will be downloaded to windows and open it in the front of user.

              In this case I need to open a ftp session on windows that will get the PDF file from IFS and open it.
              If I may ask, why FTP it? Why not open it directly from the IFS (since it's already there) in the IBM i application. If the user really wants, they could then save it to where ever they want.
              Regards

              Kit
              http://www.ecofitonline.com
              DeskfIT - ChangefIT - XrefIT
              ___________________________________
              There are only 3 kinds of people -
              Those that can count and those that can't.

              Comment


              • #8
                Re: Copy file to local pc from IFS

                Dear Haston,

                That is the only issue we do not know the no. of users and no. of pc's on that AS400 sessions are being accessed so that we can not map the drive.

                Meanwhile could you please share the code which streams the PDF files on browser.

                Thanks,

                Comment


                • #9
                  Re: Copy file to local pc from IFS

                  Dear Kit,

                  Thanks for your response.

                  We are creating a report in the form of PDF and downloading to windows pc so that user can view in GUI. Is there any way we can send the PDF to browser or put on local drive from IFS directly?

                  Thanks,

                  Mini

                  Comment


                  • #10
                    Re: Copy file to local pc from IFS

                    Basicaly you would use something like this ...
                    Code:
                    STRPCCMD   PCCMD(&DOCNAME) PAUSE(*NO)
                    where DOCNAME includes the IP address (of the IBM box), the IFS path, and the document name.
                    Search for STRPCO & STRPCCMD... there's a few examples here on code400.com.
                    Regards

                    Kit
                    http://www.ecofitonline.com
                    DeskfIT - ChangefIT - XrefIT
                    ___________________________________
                    There are only 3 kinds of people -
                    Those that can count and those that can't.

                    Comment


                    • #11
                      Re: Copy file to local pc from IFS

                      I stripped out a bunch of company logic. Hopefully it still makes sense. You'll need CGIDEV2 installed to do it this way, although you could write to the browser yourself using the HTTP API's.

                      Much of this code comes from a Scott Klement thread/post I found somewhere else.


                      Code:
                            **********************************************************************
                            * program description
                            *
                            * CGI-RPG program to add security to presenting documents over the
                            * Internet.  Once validation takes place the program will read an IFS
                            * document and write it out to the browser using CGIDEV2 routines.
                            *
                            **********************************************************************
                      
                            **********************************************************************
                            * compile options
                            **********************************************************************
                           h bnddir( 'QC2LE' )
                           h dftactgrp( *no )
                      
                            /copy cgidev2/qrpglesrc,hspecs
                            /copy cgidev2/qrpglesrc,hspecsbnd
                            **********************************************************************
                            * files
                            **********************************************************************
                      
                      
                            **********************************************************************
                            * prototypes
                            **********************************************************************
                            /copy cgidev2/qrpglesrc,prototypeb
                            /copy cgidev2/qrpglesrc,usec
                      
                      
                            **********************************************************************
                            * standalone variables and data structures
                            **********************************************************************
                           d string          s            200a
                           d fd              s             10i 0
                           d wrdata          s             24a
                           d rddata          s          32768a
                           d flags           s             10u 0
                           d mode            s             10u 0
                           d Msg             s             50a
                           d Len             s             10i 0
                           d count           s             10i 0
                           d savedQuery      s          32767a   varying
                           d session         s             15a
                           d document        s            100a   varying
                           d period          s              5a   varying
                           d customer        s              6a   varying
                           d type            s              4a   varying
                           d nbr             s             20a   varying
                           d file            s            200a   varying
                      
                            **********************************************************************
                            /free
                      
                              // populate input fields from browser query string
                              zhbGetInput( savedQuery : qusec );
                              session = zhbGetVar( 'sessionid' );
                              document = zhbGetVar( 'doc' );
                              customer = zhbGetVar( 'customer' );
                              period = zhbGetVar( 'period' );
                              type = zhbGetVar( 'type' );
                              nbr = zhbGetVar( 'nbr' );
                      
                                // if the object (PDF) exists in the IFS then read and display
                                if ChkIfsObj2( file );
                      
                                  // open IFS document for read only
                                  flags = O_RDONLY;
                                  fd = open( file : flags );
                                  if fd < 0;
                                    msg = 'open(): failed for reading' ;
                                    *inlr = *on;
                                    return;
                                  endif;
                      
                                  ClrHtmlBuffer();
                      
                                  // prepare the browser for the type of file to be shown
                                  // open it inline in the graybox window
                                  string = 'Content-Type: application/pdf' + x'25'
                                         + 'Content-Disposition: inline;  '
                                         + 'filename=' + document + '.pdf' + x'25' + x'25' ;
                                  WrtNoSection( %addr(string) : %len(%trimr(string)) );
                      
                                  // read document from IFS
                                  len = read( fd : %addr(rddata) : %size(rddata) );
                                  dow ( len > 0 );
                                    WrtNoSection( %addr(rddata) : len );
                                    len = read( fd : %addr(rddata) : %size(rddata) );
                                  enddo;
                      
                                  callp close(fd);
                      
                                else;
                                  // IFS object not found
                                  string = 'Content-type: text/html' + x'25' + x'25'
                                         + 'File not found or access restricted.';
                                  WrtNoSection( %addr(string) : %len(%trimr(string)) );
                                endif;
                      
                      
                              WrtSection( '*fini' );
                      
                              *inlr = *on;
                      
                            /end-free


                      @kitvb1 - Do you need to map a drive to the IFS for that STRPCCMD to work? I forget. If not, maybe even if ... your example is a better solution than mine. My example is from a CGIDEV2 web app.
                      Last edited by mjhaston; March 15, 2012, 09:12 AM.
                      Your friends list is empty!

                      Comment


                      • #12
                        Re: Copy file to local pc from IFS

                        Hi Mini:
                        I'm not sure I'm completely following this thread....
                        Having said that If the pc user requesting to see the pdf is logged into the Iseries/power whatever...
                        You can retrieve the device's IP address.....

                        or in rpg:


                        and ftp to that Ip address


                        Best of Luck
                        GLS
                        Last edited by GLS400; March 15, 2012, 12:37 PM.
                        The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

                        Comment


                        • #13
                          Re: Copy file to local pc from IFS

                          Originally posted by GLS400 View Post
                          Hi Mini:
                          I'm not sure I'm completely following this thread....
                          Having said that If the pc user requesting to see the pdf is logged into the Iseries/power whatever...
                          You can retrieve the device's IP address.....

                          and ftp to that Ip address

                          Best of Luck
                          GLS
                          this is provided that the PC in question has a FTP server running on it. and i highly doubt you'd want to maintain FTP servers on tons of PCs in your network...might be easier to retrieve the IP address then use QNTC to drop it on their hard drive. but it seems much easier if they could just map a network drive to a directory on the IFS instead.
                          I'm not anti-social, I just don't like people -Tommy Holden

                          Comment


                          • #14
                            Re: Copy file to local pc from IFS

                            Originally posted by mjhaston View Post
                            @kitvb1 - Do you need to map a drive to the IFS for that STRPCCMD to work? I forget. If not, maybe even if ... your example is a better solution than mine. My example is from a CGIDEV2 web app.
                            No, you only need those 2 lines in a CL pgm.
                            No mapping of drives, no FTPing of files.
                            The path I set it up in a service program that runs this program and this is used for many different types of documents.
                            Regards

                            Kit
                            http://www.ecofitonline.com
                            DeskfIT - ChangefIT - XrefIT
                            ___________________________________
                            There are only 3 kinds of people -
                            Those that can count and those that can't.

                            Comment


                            • #15
                              Re: Copy file to local pc from IFS

                              Thanks Guys. The easy solution is given by Kit to use STRPCCMD PCCMD('start \\AS400 IP\root\a.pdf') and it will open the file from IFS to your window PC.

                              Thanks all for your responses and help.

                              Comment

                              Working...
                              X