Announcement

Collapse
No announcement yet.

Please, can You help me to create a script?

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

  • Please, can You help me to create a script?

    Hello, I need a lot of help to create a script that does what I will describe later.
    This script will be used as a scheduled task inside a Windows server.
    I have installed inside a specific folder a portable B.C. just for this purpose.
    In this way, this can be customized as You want.
    Also, if to obtain what I need I must install two or more portable B.C., for example one to copy from right to left, and one from left to right, or one to copy and one to move, I will do it.

    On the right I connect to a sftp site.
    Again, if it is better to use the left side for this please tell me.

    In the remote directory "/out/orders" the customer will place text files with their orders.
    The text files will be called something like "CUSTOMER_ANNO_ORDERS_date.TXT".
    The "date" part will be YYYYMMDD, the other parts will be exactly as I wrote them.
    These files must be copied from the remote "/out/orders" to the local "T:\EDI_QLT\OUT\ORDERS".
    After that we have successfully copied them, we remove them from the remote site.

    In the local directory "T:\edi_qlt\in\ordersack" another program will write some files such as "CUSTOMER_ANNO_ORDCF_date.TXT".
    Again, the "date" part will be YYYYMMDD, the other parts will be exactly as I wrote them.
    We need to copy these files from "T:\edi_qlt\in\ordersack" to remote "/in/ordersack".
    After that we have successfully copied them, we MOVE them from "T:\edi_qlt\in\ordersack" to "T:\edi_qlt\in\ordersack\storici" (we do not touch the remote folder).

    The same for "CUSTOMER_ANNO_RECEIPT_date.TXT".
    The "date" part will be YYYYMMDD, the other parts will be exactly as I wrote them.
    Another program will write these files in the local directory "T:\edi_qlt\in\receipt".
    We need to copy these files from "T:\edi_qlt\in\receipt" to remote "/in/receipt".
    After that we have successfully copied them, we MOVE them from "T:\edi_qlt\in\receipt" to "T:\edi_qlt\in\receipt\storici" (we do not touch the remote folder).


    Please, can You help me giving me a complete script?

    Thank You very much and regards

    Rodolfo Giovanninetti

    Attached Files

  • #2
    Hello,

    Since BC4 does not support UNDO, and script does not offer a preview of actions before committing them, please test any script solutions on a clone/test data.

    I believe I've recreated a similar test set locally (using folders local and remote to simulate the local side and sftp side respectively):
    Code:
    criteria timestamp:2sec binary 
    load "d:\temp\rod\local\out\orders" "d:\temp\rod\remote\out\orders"
    select right.orphan.files
    copy right->left
    select right.exact.files
    delete right
    
    load "d:\temp\rod\local\in\ordersack" "d:\temp\rod\remote\in\ordersack"
    select left.orphan.files
    copy left->right
    select left.exact.files
    moveto "d:\temp\rod\local\in\ordersack\storici"
    
    load "d:\temp\rod\local\in\receipt\" "d:\temp\rod\remote\in\receipt"
    select left.orphan.files
    copy left->right
    select left.exact.files
    moveto "d:\temp\rod\local\in\receipt\storici"
    Please review the above code for any typos in folder names, test on test folders a few times first to make sure it logically works the way you expect, and also step through the same steps in the graphical interface (using the code as a guide) to see if it is working as you expect.
    Aaron P Scooter Software

    Comment


    • #3
      Thank You very much!
      It was already my idea to test the script using local test directories and files, but thank You anyway for this hint!
      Using this script it will handle ALL files.
      I forgot to specify that there can be also other files that must not be involved.
      So, I believe that the parts that say select exact files, and most of other lines, are ok.
      But, when I select orphan files, I want to select only files with a pattern.
      So, the first selection for right orphans must be applied only to "CUSTOMER_ANNO_ORDERS_*.TXT".
      What is the command that I must use?
      In the same way, the second orphans left selections must be applied to "CUSTOMER_ANNO_ORDCF_*.TXT".
      And the third left orphan selection "CUSTOMER_ANNO_RECEIPT_*.TXT".
      Last, instead of "d:\temp\rod\remote\..." I will have to use, AFTER tests, the remote site.
      What is the syntax that I must use?
      In the graphic interface I chose the name that I was given, such as "site.domain.it".
      Now, if I click inside the address I see "profile:<UserName>@<site.domain.it>?TEST".
      So, what must I specify in the load instruction?
      As I said, I created a portable installation just for this purpose.
      I created a session with local folder and remote site.
      I saved this session as "edi_qlt".
      Must I use something like "load edi_qlt"?
      Or something else?

      Thank You again very much for the great product and for the great support!

      Rodolfo Giovanninetti



      Comment


      • #4
        Hello,

        If you can use saved sessions, you can create a Saved Session that is your two folder names and a File Name Filter that only shows the one file you need for that specific folder pair. The load can then be:
        load "session name"

        Otherwise, the filter script command can be set each time before the load of the folder pair to limit the view to a specific file. FTP syntax can be either the Profile syntax or FTP syntax, such as:

        Code:
        criteria timestamp:2sec binary
        filter "CUSTOMER_ANNO_ORDERS_*.TXT"
        load "d:\temp\rod\local\out\orders" "profile:profile name?subfolder"
        ....
        filter "CUSTOMER_ANNO_ORDCF_*.TXT"
        load "d:\temp\rod\local\in\ordersack" "sftp://user@ip/subfolder/"
        ...
        etc
        Aaron P Scooter Software

        Comment

        Working...
        X