Skip to main content
Navigator | Tier 3
February 16, 2024
Solved

UPLOAD FOLDERS TO SFTP USING SCRIPT

  • February 16, 2024
  • 3 replies
  • 315 views

Hello Team,

I have a folder located in a local folder that needs to be transferred to an SFTP server. I possess the necessary PPK key and username for the SFTP access. The source path of the file remains constant, while the destination path may vary daily. I aim to accomplish this task by executing a CMD script within Automation Anywhere.

Can anyone help ???

I'm aware of the FTP/SFTP feature to upload/delete files in AA, but i need to know whether i can possible to upload files/folders without using the feature.

    Best answer by Tamil Arasu10

    Hi @Vaandu,

    CMD script in Automation Anywhere:

    1. Prepare your CMD script:

    • Open a text editor and create a new file (.bat extension).
    • Use the pscp command from the WinSCP package to perform the transfer.
    • The syntax is: pscp -pw <password> -i <private_key_path> <local_source_path>  <username>@<sftp_server_address>:<destination_path>

     

    Replace the placeholders with your information:

    • <password>: Leave blank if using a private key (PPK).
    • <private_key_path>: Full path to your PPK file.
    • <local_source_path>: Full path to the folder you want to transfer.
    • <username>: Username for SFTP access.
    • <sftp_server_address>: Address of the SFTP server.
    • <destination_path>: Destination path on the SFTP server (you can use variables here)

     

    2. Use the "Run Command" action in Automation Anywhere:

    • Create a new Bot in Automation Anywhere.
    • Add the "Open Program/file" action from the "Application" package.
    • In the "Command to run" field, specify the full path to your CMD script.
    • Use the "Dynamic Input" end with* and create a new variable for the daily changing destination path.
    • Map the variable to the corresponding placeholder in the CMD script using curly braces (e.g., <destination_path>{VariableName}).

    Test the script and Automation Anywhere bot thoroughly before deployment

     

    3 replies

    VaanduAuthor
    Navigator | Tier 3
    February 20, 2024

    @Tamil Arasu10  can you suggest your solution?

     

    Tamil Arasu10
    Most Valuable Pathfinder
    Most Valuable Pathfinder
    February 20, 2024

    Hi @Vaandu,

    CMD script in Automation Anywhere:

    1. Prepare your CMD script:

    • Open a text editor and create a new file (.bat extension).
    • Use the pscp command from the WinSCP package to perform the transfer.
    • The syntax is: pscp -pw <password> -i <private_key_path> <local_source_path>  <username>@<sftp_server_address>:<destination_path>

     

    Replace the placeholders with your information:

    • <password>: Leave blank if using a private key (PPK).
    • <private_key_path>: Full path to your PPK file.
    • <local_source_path>: Full path to the folder you want to transfer.
    • <username>: Username for SFTP access.
    • <sftp_server_address>: Address of the SFTP server.
    • <destination_path>: Destination path on the SFTP server (you can use variables here)

     

    2. Use the "Run Command" action in Automation Anywhere:

    • Create a new Bot in Automation Anywhere.
    • Add the "Open Program/file" action from the "Application" package.
    • In the "Command to run" field, specify the full path to your CMD script.
    • Use the "Dynamic Input" end with* and create a new variable for the daily changing destination path.
    • Map the variable to the corresponding placeholder in the CMD script using curly braces (e.g., <destination_path>{VariableName}).

    Test the script and Automation Anywhere bot thoroughly before deployment

     
    _Tamil_
    VaanduAuthor
    Navigator | Tier 3
    February 20, 2024

    thanks @Tamil Arasu10 for the great support