3 Replies Latest reply on Oct 21, 2019 7:37 AM by miladmeh8

    How to export workflow log to an external resource like ftp or smb server?

    miladmeh8 Novice

      Hi all,

      Recently i wrote an workflow to get all storage path status, but i need to save all of the result into an external resource like ftp or smb servers.

      Can anyone suggest me the best practice?

       

       

      Thank you

        • 1. Re: How to export workflow log to an external resource like ftp or smb server?
          eoinbyrne Hot Shot

          SMB would probably require providing Command access which is a security risk so FTP is safer & vRO has an FTP client class

           

           

          You can use it to either

          - send content to a remote file

          this one is simple

           

          var content = "some content";

          ftpClient.putContent(content, "remotefile.txt");

           

          - create a local file on the vRO appliance and upload that.

           

          You will need to have the capability to create a local file on the vRO appliance but you can the following to create a temp file and write your content to it, then upload to the remote with the desired name.

           

          // assume your file content is in this var

          var fileContent = "whatever the content should be";

          var localFile = System.createTempFile(".txt"); // create a temp file with the given suffix

          FileWriter fw = new FileWriter(localFile);

          fw.open();

          fw.write(fileContent);

          fw.close();

           

          var localFileFullName = localFile.path + "\" + localFile.name

          // do the FTP upload here

          ftpClient.putFile(localFileFullName, "whatever the name at the remote should be");

          1 person found this helpful
          • 2. Re: How to export workflow log to an external resource like ftp or smb server?
            miladmeh8 Novice

            Thank you for your response

            But where should i define my ftp server address and credentials?

            • 3. Re: How to export workflow log to an external resource like ftp or smb server?
              miladmeh8 Novice
              1. var ftp = new FTPClient(); 
              2. ftp.connect("10.20.123.135", "21");  // sample ip, port 
              3. ftp.login("user", "pass");  // sample username, password 
              4. System.log("cwd -> " + ftp.cwd); // print current directory 
              5. ftp.makeRemoteDirectory("/tmp6");  // create a new directory 
              6. ftp.cwd = "/tmp6";  // changes current directory to the newly created one 
              7. System.log("cwd -> " + ftp.cwd);  // print the new current directory 
              8. ftp.disconnect();