Skip to main content

I am having trouble with "ftpput" and "ftpget" in a script.

User macros are done through AnzioWin with a specific syntax in most cases. The usual problem with the ftpput, sftpput, ftpget and sftpget is the missing host parameters. Currently the host parameter IS NEEDED. This may change in the future, but for now it must be included. However, it can be an empty string such as the following:

/usr/bin/printf "\034%s\035" "ftpput \"\" c:\\temp\\mytest.pdf"

The double-quotes in the command represent the host name and force AnzioWin to use the actual PC file name (without the directory information). Also note that you may have to escape the backslashes in this string, depending on your shell and scripting. You can provide the host name if you wish:

/usr/bin/printf "\034%s\035" "ftpput mynew.pdf c:\\temp\\mytest.pdf"

Another common problem is understanding that you MUST log in before performing a file transfer over FTP. One advantage you have with AnzioWin, if you have the login wizard enabled and a username and password included, the login for your FTP or SFTP will be automated when doing transfers through scripts. An alternative is to provide the host login information within the file transfer string itself (password can be optional if one is not required by your ftp server):

/usr/bin/printf "\034%s\035" "ftpput username[:password]@hostname/hostfilename pcfilename"

An example might look like this:

/usr/bin/printf "\034%s\035" "ftpput jdoe:fido123@server2/mynew.pdf c:\\temp\test.pdf"

The other, most common problem is using wildcards and understanding how this works. The minimum syntax for "ftpput" and "sftpput" requires the PC file name:

ftpput "" <PC filename>

The PC filename can be a wildcard or a list of files to transfer:

ftpput "" c:\temp\*.pdf

ftpput "" c:\temp\myfiles.*

ftpput "" c:\temp\inv-????.pdf

ftpput "" c:\temp\inv-0020.pdf,c:\temp\inv-0021.pdf,c:\temp\inv-0022.pdf

(remember that you may have to escape the backslashes and enclose the file names in quotes if there are any embedded spaces).

In doing WILDCARDS or a file list, you also need to be aware that the host name should either be left empty or it can be a directory on the server. You must have write permissions for the "put" to be performed to a specified directory. A list of file names to transfer "as" is not supported at this time.

For server file transfers, sftpget and ftpget, you can also specify a set of wildcard strings, similar to those above. And like the above, the PC file name should be left blank or be a directory name with write permissions. A list of file names to transfer "as" is not supported at this time.

In both cases, if you do not specify a host or PC directory (depending on the upload or download direction), the default will be used. For putting files on the host, the upload default directory is the first directory logged into with your username and password. For the PC download default directory, the directory is that specified in the "Transfer Options". If none is specified, the current working directory is the default.

Note - Wildcard transfers first appeared in AnzioWin version 15.2j for sftpput and sftpget. AnzioWin versions later than version 16.2 supports wildcards in the FTP protocol as well (ftpput and ftpget). Please contact us for more information if you are having problems and want to use this feature.

Copyright © 2024 Rasmussen Software, Inc. Legal Information & Privacy Policy
Send comments and suggestions to rsi@anzio.com