Generate/SecureFXsysicon.jpg  Command-Line Utility


The SFXCL command-line utility allows you to perform tasks from the command line. The utility recognizes general command-line instructions (which all use a similar syntax) as well as the additional QuickSync option that requires a specific syntax.

General Command-Line Instructions

General command-line instructions use the following syntax:

SFXCL [Option] Source [Source] [Source...] Destination

Source parameters may be either a file or folder, and can contain wildcard characters. In other words, an asterisk (*) may be used to represent zero or more characters, or a question mark (?) may be used to represent a single character.

The table below lists the general command-line options recognized by SFXCL with their applicable arguments.

Option

Argument

Description

/AcceptHostKeys

 

Instructs SFXCL to automatically accept host keys from the server, eliminating prompts for the user to accept new host keys. This option only applies when the protocol is SFTP.

/Command

command

Sends the specified command to the FTP server before the transfer operation.  If the transfer is server-to-server, the command is sent to the destination server.  Multiple commands can be specified. Example uses of this option can found in the Examples of General Command-Line Instructions section below.

/ConfigPassphrase

passphrase

Specifies the configuration passphrase. This option allows SFXCL to run unattended when the configuration is passphrase protected.

/Credentials title Specifies a set of saved credentials to use. The username and authentication methods specified in the saved credentials will be used when connecting the SFTP or SCP server.

/DefaultType

prompt

If a file does not have a defined file type, this will prompt you for the transfer type that you want to use.

 

ascii

If a file does not have a defined file type, this will transfer the file in ASCII.

 

binary

If a file does not have a defined file type, this will transfer the file in binary. This is the default value.

/F

path

Specifies the location of the SecureFX configuration folder.

Note: If you want to schedule a command that will run as System, you must provide the path to your Config folder with the command.

/Firewall

firewall
name

Connects session using specified firewall settings. The format of this command is as follows:

/ Firewall=<name>

If the firewall name contains spaces, it should be enclosed by quotation marks.

Note: The /Firewall command must come before the /S session command.

If no firewall argument is specified, SecureFX will use the firewall specified by the session being connected. If the session firewall is set to None, SecureFX will use the firewall specified in the Default Session. If a firewall is named in the command argument, SecureFX will temporarily override the session’s firewall settings and use the firewall specified for the current session (see example below).

Note: This command cannot be used in conjunction with the /QuickSync or /Synchronize commands.

/I

path/filename

Specifies the identity file to use with public-key authentication [The process of verifying that an individual truly is who he or she claims to be. Supplying a password is a very common method of authentication.] . When this option is used, public key becomes the primary authentication method.

/Log

path/filename

Turns on logging for the SFXCL session and writes to the specified file. If a password is specified on the command line, it will not be written to the log file; this is not optional.

Use /Log:o to specify that the log file should be overwritten when opened.

/MaxParallel

value

Specifies the maximum number of parallel transfers. Valid values are integers between 1 and 2147483647. Specifying this option on the command line overrides the global option Maximum number of parallel transfers.

/NoPrompt

 

Causes SFXCL to dismiss all user input prompts as though the user clicked on the Cancel button or pressed the ESC key. In most cases (e.g., username and password prompts), using this option will cause SFXCL to exit with an error.

/NoTempFiles

 

Instructs SFXCL to not create intermediate temporary files during synchronize operations. When this flag is set, the file is transferred directly from the source to the destination without the creation of a ".vs_temp" file. This option only works in conjunction with the /QuickSync option.

/Overwrite

prompt

If a destination file already exists, this will prompt you to overwrite the file or not.

Note: The /Overwrite option is only valid with regular transfers. It cannot be used with /Synchronize or /QuickSync commands.

 

always

If a destination file already exists, this will always overwrite the file. This is the default value.

 

never

If a destination file already exists, this will never overwrite the file.

 

older

If a destination file already exists, this will overwrite the file if it is older than the source.

 

resume

 This argument can be used to resume an interrupted transfer.

/P

passphrase

Specifies the passphrase to use for public-key authentication.

/Password

password

Specifies a password to use with a specific session and can be used as a temporary password for that session. For example:

sfxcl.exe /password myPassword /QuickSync c:\users\me\ mySession c:\users\me\logs

This option also works as part of a connection where a URL is specified. For example:

sfxcl.exe /password myGoodPassword sftp://me@redhat8/*.patch  c:\users\me\

The password specified with this option takes precedence over any password specified as part of a URL.

/Q

 

Keeps SFXCL from sending its output to the screen.

/ReconnectCount

count (0..32767, infinite)

Specifies the number of times to try to reconnect after a disconnect. This option is only valid with transfer operations.

This is similar to the /RetryCount command line switch but differs from it in that RetryCount only takes effect after a failed connection attempt, where as ReconnectCount only takes effect after a disconnect.

Note that the internal recconect count is reset after a file is transferred successfully.

/ReconnectDelay

seconds

Specifies the number of seconds to wait between losing a connection and the initial reconnect attempt.

/RetryCount

count (0..32767, infinity)

Specifies the maximum attempts allowed to re-establish a connection.

/RetryDelay

seconds

Specifies the number of seconds to wait between connection retries.

/TraceLevel

value

Specifies the trace level to use for trace output. Valid values are integers between 0 and 9. Specifying this option on the command line overrides the session option SecureFX Trace Level.

/TransferType

ascii

Overrides any transfer types for all of the transfers specified in the command line. If a transfer type is specified for a particular file (using something like the /S:type=a option), that option will override the /TransferType option for that particular file.

 

binary

Overrides any transfer types for all of the transfers specified in the command line. If a transfer type is specified for a particular file (using something like the /S:type=a option), that option will override the /TransferType option for that particular file.

/Version   Displays version information.

 

The table below lists the source and destination parameters recognized by SFXCL with their applicable arguments.

Source /
Destination

Description

URL

Transfers files to or from the specified URL.

SFTP URLs must be in the following format:

sftp://[<user>[:<password>]@]<host address>[:<port>][/<path>][;<type=a|i|d>]

SCP URLs must be in the following format:

scp://[<user>[:<password>]@]<host address>[:<port>][/<path>][;<type=a|i|d>]

FTP/TLS URLs must be in the following format:

Implicit 

ftps://[<user>[:<password>]@]<host address>[:<port>][/<path>]:

Explicit

ftpes://[<user>[:<password>]@]<host address>[:<port>][/<path>]:

FTP URLs must be in the following format:

ftp://[<user>[:<password>]@]<host address>[:<port>][/<path>][;<type=a|i|d>]

HTTPS URLs must be in the following format:

https://[<user>[:<password>]@]<host address>[:<port>][/<path>]

HTTP URLs must be in the following format:

http://[<user>[:<password>]@]<host address>[:<port>][/<path>]

The <path> component can be either relative (no leading "/" character) to the home folder in which a user is placed after authentication, or absolute (includes a leading "/" character).  Appending the URL with the ";type=a|i|d" argument will specify the file type: ascii, image, or directory.

Relative path example – this example transfers all .txt files located in the "subfolder" directory of the user's "home" folder to c:\temp on the local machine:

SFXCL  /Log c:\temp\sfxcl_log.txt sftp://user:p4$$w0rd@myhost:2222/subfolder/*.txt  c:\temp

Absolute path example - This example transfers all files in the /usr/local/etc directory on the remote machine containing "vshelld" in their name to the c:\backup folder on the local machine:

SFXCL  /Log c:\temp\sfxcl_log.txt sftp://user:p4$$w0rd@myhost:2222//usr/local/etc/*vshelld* c:\backup

Hostname

Transfers files to the specified host or IP address [Every site that is reachable on the Internet must have a valid IP, or Internet Protocol,address. An IP address should be entered as four numbers separated by period (.) characters (for example: 198.105.232.1).]

/S
session path

 

Transfers files to or from the specific session.

The session path must be the full path of a session profile in the database as in the following example:

"/Software/Commercial Software/VanDyke Software"

If the pathname contains spaces, enclose it in quotation marks.

Note: The root folder "Sessions" should not be included in the path to a session when using the command line utility. Use a "/" instead.

The following is the syntax for the /S option with arguments:

/S[:[<argument>[,<argument>]]] <session_path>

Adding the ":i" argument to the /S command (i.e., /S:i) will specify that SFXCL use the session's initial directory.  

Appending the /S command with the ":type=a|i|d" argument instructs SFXCL as to the type of the file/folder specified as the remote source: ASCII, image, or directory.

Use "/S:type=a" to specify that the target is an "ASCII" file type.

Use "/S:type=i" to specify that the target is an "image" file type (binary).

Use "/S:type=d" to specify that the target is a "directory". This specification overcomes a bug in problematic MVS FTP servers that don't provide a reliable way for SFXCL to automatically detect whether the target specified is a file or a folder.

Arguments can be combined with a "," character if both "i" and "type" are needed. For example, to instruct SFXCL to use the initial remote directory specified in session options as well as designate the file type as ASCII, you would use the following command:

/S:i,type=a session_path file_name

Here's an example SFXCL command line specifying that the remote ASCII file "A008546" should be downloaded from the "My Remote Host" session's initial remote directory (as defined in the session options for "My Remote Host") to the C:\Downloads location on the local host:

SFXCL.exe  /Log c:\DebugLog.txt  /S:i,type=a "My Remote Host" A008546  C:\Downloads

If the "type" argument does not provide the results that you require, SFXCL also supports an alternative to the "type" argument in the form of the "TransferType" and "Attr" arguments.

TransferType: This option allows the transfer type to be specified independently of the file type (unlike the "type" option).

Attr: This option allows the file type to be specified independently of the transfer type (unlike the "type" option).

The "Attr" and "TransferType" arguments are intended to be used separately or together (and instead of "type"). You should not use the "type" option with either "Attr" or "TransferType".

Examples of General Command-Line Instructions

Transferring a file from the Policies folder of the Headquarters session to the Presentation folder on a local drive and renaming the file.

SFXCL.exe /S /Headquarters /Policies/Mission.txt "c:\My Documents\Presentation.txt"

Transferring two files from two remote source folders to one local destination folder:

SFXCL.exe /S /Ops /Bob/Payroll.txt /S /Ops /Alice/Memo.txt "c:\My Documents"

Transferring local files to a session folder with a prompt to overwrite if the files already exist.

SFXCL.exe /Overwrite prompt c:\Memo1.txt d:\Memo2.txt /S /Headquarters "/The Boss/Memos/"

Transferring Word and Excel (.doc and .xls) files from a local documents folders to a remote host.

SFXCL.exe "c:\My Documents\*.doc" "c:\My Documents\*.xls" ftp://ftp.mysite.com/users/bob/documents

Transferring documents using SFTP.

SFXCL.exe sftp://username:password@OurSFTPServer/pub/vim/vim57 c:\downloads\vim

Transferring files using HTTPS:

https://username:password@OurHTTPServer/pub/documents C:\downloads\

Examples of server-to-server transfers:

SFXCL.exe /S /Ops /Alice/Memo.txt /S /Headquarters "/The Boss/Memos/"

SFXCL.exe sftp://user:password@Server1/home/user/logs/*.log sftp://user:password@Server2/home/user/log_archive

Example uses of the /Command option:

SFXCL /Command "QUOTE SITE standard=none" /Command "QUOTE SITE parm=sa=sender_address;ra=receiver_address"

/S /Ops /Bob/Payroll.txt  "c:\My Documents"

SFXCL /Command "QUOTE SITE standard=none" /Command "QUOTE SITE parm=sa=sender_address;ra=receiver_address"

C:\My Documents\Payroll.txt  /S /Ops /Alice

Other Command-Line Operations

Option

Argument

Description

/QuickSync

path

Initiates a comparison operation between a local folder and a folder on a remote server, and transfers files according to the argument specified.

The /QuickSync operation must be entered on the command line with the following syntax:

SFXCL.exe /QuickSync <local path> <session path> <remote path> <upload | download | mirror-both | mirror-local | mirror-remote> [no-subdir]

For example, to mirror a local folder with a remote folder:

SFXCL.exe /QuickSync "c:\My Documents" "/SSH2Session" /Users/Bob/Docs mirror-both

Note: Wildcard characters cannot be used in the remote path field of a /QuickSync command.

The /QuickSync command can be used with the [no-subdir] switch if you do not want to include subdirectories in the operation.

/Synchronize

synchronize session name

Initiates a synchronize operation using the synchronization settings saved for the specified session.

/Delete

path

Deletes the specified files or directories. Deleting local files is not allowed

The /Delete operation cannot be combined with other file operations on the same command line. If this operation is specified, all remote items listed on the command line will be deleted unconditionally.

Multiple remote items may be specified on a single command, and the items specified may contain wildcard characters.

The syntax for the /Delete operation is as follows:

SFXCL.exe [options] /Delete remotesource [ remotesource [...]]

/List

directory

Displays directory listing. If no directory is specified, this option will display the listing for the SFTP startup directory on the remote machine. This option will not give a listing for a specified file.

/Move

 

When this option is specified, all successfully transferred files are deleted from the source directory. Any folders and subfolders that were successfully transferred are also deleted.

/Parsable

 

Use this option in conjunction with the /List command to output the directory listing in MLSD/MSLT format, which is easier to parse.

This option should come before /List on the command line. The syntax is as follows:

SFXCL /Parsable /List <dir>

/Rename

path

Renames files or directories from the command line.

The syntax for the /Rename operation is a follows

SFXCL.exe /rename remotesource [remotesource [...]] newname

For example, to rename a folder:

SFXCL.exe /Rename /S /Headquarters /Policies OldPolicies

Or, to rename a file:

SFXCL.exe /S /Ops /Bob/Payroll.txt PayrollMay.txt

/Chmod

path

Changes the permissions of the specified files or directories on the remote system. The syntax for the /Chmod operation is as follows:

SFXCL.exe /Chmod <octal mode> remotesource [remotesource [...]]

Returned Values

After SFXCL completes a run, it returns a value to the initiating entity (application, batch file, etc.). If the run was successful, the program will return a zero (0). If the run had any errors, one of the following exit codes will be returned:

Generate/BULLET.gif    Exit code 100 is returned for network errors, such as being unable to connect or the user cancelling the username or password prompt.

Generate/BULLET.gif    Exit code 200 is returned for source file system errors, such as "file not found".

Generate/BULLET.gif    Exit code 300 is returned for target file system errors, such as not being able to write the target file due to insufficient permissions.

Generate/BULLET.gif    Exit code 400 is returned for general failures, such as an invalid command line or the user cancelling the configuration passphrase prompt.

The returned value can be used by other applications. For example, see the following batch file.

SFXCL /quicksync C:\MyDocuments MySession /pub/docs download

if not errorlevel 0 goto fail

if errorlevel 0 goto success

 

Related Topics

  1. Command-Line Usage