How To Guide

Using Robot Schedule Enterprise Agent Jobs to Transfer Files

Last Updated:
August 25, 2016

Before You Begin

These instructions describe how you transfer files using Robot Schedule Enterpise agent jobs.

To ensure that a command runs from an agent job, do the following:

  1. Log in directly to the agent system.

  2. Start cmd.exe in Windows or a regular shell in Linux or UNIX.

  3. Enter the command exactly the way you want to run it from an agent job.

If interactive prompts appear, take appropriate steps to ensure they do not appear when the command runs in unattended batch mode. Adjust the command and its parameters until it works correctly from the command line on the agent system. After the command has been verified, you can use it in an agent job.

Using FTP to Transfer Files

To use FTP from a Robot Schedule Enterprise job, do the following:

  1. Create an FTP script for the FTP client program on the agent sytem. The following is an example of an FTP script:

    user username password
    get /path/to/remote/file /path/to/local/destination/file

  2. Save your script in a file called "ftpscript." Use the following command to run the script from a Linux or UNIX agent job:

    cat ftpscript

    Use the following command to run the script from a Windows agent job:

    ftp -n -i -s:ftpscript

Note: The FTP client program on your agent system may allow you to create more complex FTP scripts. Consult the help or documentation for your FTP client program for more information.

You can create, execute, and clean up a script directly in your agent job. This keeps the process in a single location for easier maintenance. The following example for Linux and UNIX. Each line is a line in the agent job’s Command Entry tab.

#first make the script file
echo "open" > ftpscript
echo "user username password" >> ftpscript
echo "binary" >> ftpscript
echo "get /path/to/remote/file /path/to/local/destination/file" >> ftpscript
echo "close" >> ftpscript
echo "bye" >> ftpscript
#now the ftp script has been created
#launch ftp using the script as the standard input to transfer the file
cat ftpscript #the file should have transferred
#now get rid of the ftp script file
rm ftpscript

The following example shows the script translated for use on a Windows agent:
REM first make the script file

echo open > ftpscript
echo user username password >> ftpscript
echo binary >> ftpscript
echo get /path/to/remote/file /path/to/local/destination/file >> ftpscript
echo close >> ftpscript
echo bye >> ftpscript
REM now the ftp script has been created
REM launch ftp using the script
ftp -n -i -s:ftpscript
REM the file should have transferred
REM now get rid of the ftp script file
del ftpscript

Using SSH to Transfer Files

Note: The FTP clients described in this topic are given only as suggestions from HelpSystems, and are not supported. If you need assistance using these programs, contact the vendor for the program.

You need a client to use SSH-based file transfer protocols on Windows (SFTP and SCP). PuTTY is an SSH-based FTP client that includes clients for SFTP and SCP and can be downloaded at:

Note: Most Linux distributions already have SSH, SFTP, and SCP clients installed by default. If your UNIX or Linux distribution does not include these clients, please contact your distribution’s support center to see if one can be installed.

When using SSH-based transfer programs, interactive prompts may appear asking you to accept a server’s signature or provide a user password. Robot Schedule Enterprise agent jobs do not handle these interactive prompts, and the job appears to be stuck in Running status. For the agent job to be successful, create the file transfer commands with arguments that allow the password to be included on one command line. Or, establish a public key encryption exchange between the two accounts transferring files so that a password is not needed. The examples using SCP and SFTP in this document require that the encryption key not be protected with a passphrase.

Using SCP from a Robot Schedule Enterprise Agent Job

To use secure copy protocol (SCP) with SSH to transfer a file using a Robot Schedule Enterprise agent job, consider the following prerequisites:

  • The agent system where the job is running must have an SSH-capable client that includes an SCP command (Windows users can use PSCP installed with PuTTY).

  • The Host system you are connected to with SCP must be running an SSH-capable server that supports SCP.

  • The user on the agent system running the agent job must be connected to the host system with SSH and accepted the host’s key. If this prerequisite is not met, the agent job stops while waiting for interactive acceptance of the host’s public key, resulting in the agent job hanging up on the agent. To ensure successful job completion, log on normally to the agent system and use PuTTY to create an SSH connection to the host system. Once you do this, the agent job with an SCP command runs normally, as long as the host’s public key doesn’t change and the acceptable SSH host keys are not purged for the agent system’s user.

  • To run SCP commands without passwords, set up the appropriate SSH encryption keys between the user accounts and systems as needed. Otherwise, specify the password as part of the SCP command in the agent job.

  • For Linux or UNIX, you typically need to have a previously set up SSH connection to allow key authentication instead of passwords to use SCP. Also, the correct keys must already have been exchanged to allow access. On UNIX, a SCP command might look as follows:

    scp -B /path/to/local/destination

    PuTTY allows you to enter a password as an argument to PSCP. The Windows PSCP command would look like this:

    pscp -pw password /path/to/local/destination

    The Windows directory containing the PSCP program must be part of the user’s PATH environment variable, or the full path to PSCP must be specified. (Usually this is "c:\Program Files\Putty\" or "c:\Program Files (x86)\Putty" for 64-bit Windows.)

Using SFTP from a Robot Schedule Enterprise Agent Job

Note: Read the section on SCP file transfers before continuing with SSH File Transfer Protocol (SFTP).

You can use SFTP from a Windows agent job in a similar manner to regular FTP by using an ftp script. PuTTY contains an SFTP client called PSFTP. To run completely unattended in a Robot Schedule Enterprise agent job, consult PuTTY’s documentation on how to set up the public key authentication. Once that has been successfully set up and tested, you can use PSFTP with PSFTP scripts to transfer files. The following is an example. Note that the script does not include the server, user name, or user password.

get \path\to\the\file \local\path

For this example, the private key is located in the file "C:\Documents and Settings\Administrator\My Documents\sshprivatekey.ppk". In a Windows agent job, run the script with the following command:

pSFTP -b SFTPscript -i "c:\Documents and Settings\Administrator\My Documents\sshprivatekey.ppk"

The script can also be created by the job, run, and then removed all in one agent job:

REM first make an ftp script with the commands you want
echo get \path\to\the\file \local\path > SFTPscript
echo close >> SFTPscript
echo bye >> SFTPscript
REM the script SFTPscript has been created
REM launch pSFTP and use the script
pSFTP -b SFTPscript -i "c:\Documents and Settings\Administrator\My Documents\sshprivatekey.ppk"
REM clean up the file SFTPscript
del ftpscript

A similar method can be used to automate an SFTP file transfer in an agent job for Linux or UNIX. The SSH public key encryption needs to be set up and needs to be tested and shown to be working before running SFTP commands from an agent job.

The following is a sample SFTP script for UNIX. Notice that the script does not include the server, user name, or user password.

get /path/to/the/file /local/path

The script can be run from an agent command as follows:

sftp -b sftpscript

The script can also be created by the job, run, and then removed all in a single agent job:

#first make an ftp script with the commands you want
echo "get /path/to/the/file /local/path" > sftpscript
echo "bye" >> SFTPscript
#the script SFTPscript has been created
#launch sftp and use the script
SFTP -b sftpscript
#clean up the file sftpscript
rm ftpscript

Using FTPS from a Robot Schedule Enterprise Agent Job

You can use Curl retrieve files in automated scripts. It is available in most Linux distributions as an optional package and can also be found for Windows. Curl can be used to retrieve a file from a remote server that is configured to allow ftps transfers. The following example shows how to retrieve a file using Curl:

curl --insecure --ftp-ssl ftp://USERNAME:PASSWORD@FTPS.SERVER.COM/path/to/file.txt > file.txt

In this example, the remote file "/path/to/file.txt" ends up in the local directory as file.txt. If the remote server has a certificate that has been signed by a proper Certificate Authority, you can omit the "--insecure" option.

A free FTPS client for Windows is MOVEit Freely. You can download it at:

The MOVEit Freely client program is called ftps.exe. You can write scripts for ftps.exe in a similarly to ftp scripts. For example, the following script gets two files:

get /path/to/file.txt
get /path/to/file2.txt

Use the following command to execute the ftpsscript commands from an agent job:

ftps -e:on -user:username -password:password -z -s:ftpsscript

If the SSL certificate of the server is properly signed, you can remove the "-z" option from the command. However, if it is removed and the server’s certificate is not properly signed, the agent job remains in Running status because an interactive prompt on the agent system asks if it is OK to continue with an invalid certificate.


Related Products