Script

FTP

The professional tool to automate FTP, SFTP, FTPS

and schedule FTP batch jobs

MENU MENU
Post here if you experience file transfer problems or unexpected errors.
Dear all,

I am interested in purchasing scriptFTP but have a few queries regarding its functions before making my purchase.

My current setup:
- FTPS server which holds reports
- reports that have been downloaded cannot be downloaded again but remain in the same workspace.
- connection type: ftpes - ftp over explicit tls/ssl

I need a script for scriptftp such that it downloads "only" files in the directory that are new (non-downloaded before).

Any suggestions are welcome. I'm still looking for an answer in the sample scripts section.
Hello,
I need a script for scriptftp such that it downloads "only" files in the directory that are new (non-downloaded before).
Try the following:
FTP Script
  1. # Change current protocol to explicit FTPS
  2. SETPROTOCOL(FTPS_EXPLICIT)
  3.  
  4. # Connect to FTPS server
  5. OPENHOST("ftp.myhost.com","myuser","mypassword")
  6.  
  7. # Synchronize a local directory from an FTP site
  8. SYNC("C:\example_dir","/example_dir",DOWNLOAD,SUBDIRS)
  9.  
  10. # Close connection
Thanks for the reply!~

However, I'm having an issue with regards to getfile(*.*) or GETFILE("/folder/*.*") as well as listfile.

Whenever I use those functions, it's unable to view or list any files in the folder.

But getfile works when I hardcode the full file path name but this is not what I'm looking for.

Could you kindly advise if there's any workaround solutions?

Many thanks!
Try setting the current remote directory with CHDIR first.
FTP Script
  1. CHDIR("/myremotedir")
  2. GETFILE("*.*")
Try also using "*" instead of "*.*". May be GETFILE and GETLIST are not showing any file because they do not contain a dot in the filename. For example if a file is called "README" with no extension (.txt, .doc or whatever) it will not match "*.*"
FTP Script
  1. GETFILE("/myremotedir/*")
And if the problem persits please post here again.
Thanks again!

For some reason, it still doesn't work, nothing happens
GETFILE("/foldername/*")

CLOSEHOST
Disconnected.
However, if I hardcode the full filename, it works.

All files within the folder should have .zip or .csv extension. (ie: file.zip or file.csv)
Mmmm, not sure about what could be happening. Try enabling verbose mode putting the command VERBOSE(ON) on the top of your script file and post here the output, please. This switch will make ScriptFTP to show very detailed information about the FTP session.

Remember to remove your password or any private information. It will be shown on the top ;)
Thanks!!!

FTP Script
  1. VERBOSE(ON)
  2. SETPROTOCOL(FTPS_EXPLICIT_ENCRYPT_DATA)
  3. SETPORT(38021)
  4. OPENHOST("ftp.xxx.xxx.com.hk","Username","password goes here")
  5. CHDIR("/Username")
  6. LOCALCHDIR("C:\Users\DTdude\Documents\AFD")
  7. GETFILE("/Username/*")
Please see output as follows:

VERBOSE(ON)
Running D:\Users\DTdude\Documents\AFD\AFD.ftp
Verbose mode enabled

SETPROTOCOL(FTPS_EXPLICIT_ENCRYPT_DATA)
Setting protocol to FTP over SSL (explicit with data channel encryption).
Setting TCP port to 21.

SETPORT("38021")
Setting TCP port to 38021.

OPENHOST("ftp.xxx.xxx.com.hk","Username",******)
Connecting to ftp.xxx.xxx.com.hk
Resolving host name "ftp.xxx.xxx.com.hk"
Connecting to xxx.xxx.xx.xx Port: 38021
Connected to ftp.xxx.xxx.com.hk.
220 <<<Connect:Enterprise UNIX 2.4.02 Secure FTP>>> at HKP01LP1041 FTP server ready. Time = 14:11:06
AUTH TLS
234 AUTH TLS-C/TLS OK.
Connected. Exchanging encryption keys...
Session Cipher: 128 bit RC4
SSL encrypted session established.
PBSZ 0
200 PBSZ 0 OK.
USER Username
331 Password required for Username.
PASS passwordgoeshere
230 Connect:Enterprise UNIX login ok, access restrictions apply.
SYST
215 UNKNOWN Type: L8
FEAT
500 'FEAT': command not understood.
TYPE I
200 Type set to I.
REST 0
550 Operation is not supported under Connect:Enterprise FTP server.
PWD
257 "/Username" is current directory.
Connected.
Checking if MLSD works in this serverPROT P
200 PROT P OK, data channel will be secured.
PASV
227 Entering Passive Mode (203,112,90,74,125,200)
Opening data connection to 203.112.90.74 Port: 32200
LIST
Connected. Exchanging encryption keys...
150 Opening BINARY mode data connection for .
Session Cipher: 128 bit RC4
SSL encrypted session established.
423 bytes transferred. (8.78 KB/s) (47 ms)
226 Transfer complete.

CHDIR("/Username")
Changing current remote directory to /Username
CWD /Username
250 CWD command successful.
PWD
257 "/Username" is current directory.

LOCALCHDIR("C:\Users\DTdude\Documents\AFD")
Changing current local directory to C:\Users\DTdude\Documents\AFD

GETFILE("/Username/*")

CWD /Username/
250 CWD command successful.
PWD
257 "/Username" is current directory.
PASV
227 Entering Passive Mode (203,112,90,74,125,201)
Opening data connection to 203.112.90.74 Port: 32201
LIST
Connected. Exchanging encryption keys...
150 Opening BINARY mode data connection for .
Session Cipher: 128 bit RC4
SSL encrypted session established.
423 bytes transferred. (8.78 KB/s) (47 ms)
226 Transfer complete.
CWD /Username
250 CWD command successful.
PWD
257 "/Username" is current directory.

CLOSEHOST

QUIT
221 Goodbye.
Server closed connection
Disconnected.

Any help is greatly appreciated.
LIST
Connected. Exchanging encryption keys...
150 Opening BINARY mode data connection for .
Session Cipher: 128 bit RC4
SSL encrypted session established.
423 bytes transferred. (8.78 KB/s) (47 ms)
It seems that the remote directory contains some files (the file list sent from the server has 423 bytes) but the wildcard * does not match with any of them.... :|

I would need access to your FTP server to see exactly what is happening there. Contact me by email if you want me to do so.
I am experiencing the same problem.
What was the fix for this issue?

I'm working with a 3rd party vendor and cannot release username and password, but if needed I can work with them in resolving it.

Thank you,
Igor
Hi,

I am writing to see if you could help me resolve a similar issue. I can't use a wild card to download or list files. This is the script i am using in it's simplified form.
FTP Script
  1. VERBOSE (ON)
  2.     SETPROTOCOL(FTPS_EXPLICIT_ENCRYPT_DATA)
  3.     SETPASSIVE(ENABLED)
  4.     SETTYPE(ASCII)
  5.  
  6.         $server="xxxxxxxxxxxxx"
  7.     $username="xxxxxxxxxx"
  8.     $password="xxxxxxxx"
  9.    
  10.     $result=OPENHOST($server,$username,$password)
  11.    
  12.     SETCLOCKDIFF(3600)
  13.  
  14.     LOCALCHDIR("C:\download")
  15.  
  16.     GETLIST($list,REMOTE_FILES,"*.*")
  17.         $amount=COUNTELEMENTS($list)
  18.         PRINT("Found ".$amount." files")
  19.        
  20.     GETFILE("/remotefolder/*.*")
  21.     CLOSEHOST()
GETLIST(REMOTE_FILES,"*.*")
Getting file listing of current remote directory
TYPE I
200 Type set to I.
PROT P
200 PROT command successful
PASV
227 Entering Passive Mode (12,129,29,5,255,172)
Opening data connection to xx.xxx.xx.x Port: 65452
LIST -T
Connected. Exchanging encryption keys...
150 Opening BINARY mode SSL data connection for file list.
Session Cipher: 128 bit Unknown
TLS encrypted session established.
226 Transfer complete.
403 bytes transferred. (1.47 KB/s) (266 ms)
Found 0 files.
No files were found

GETFILE("/remotefolder/*.*")
CWD /remotefolder/
250 CWD command successful.
PWD
257 "/remotefolder" is current directory.
TYPE A
200 Type set to A.
PASV
227 Entering Passive Mode (12,129,29,5,255,173)
Opening data connection to xx.xxx.xx.x Port: 65453
LIST -T
Connected. Exchanging encryption keys...
150 Opening ASCII mode SSL data connection for file list.
Session Cipher: 128 bit Unknown
TLS encrypted session established.
403 bytes transferred. (834 bytes/s) (483 ms)
226 Transfer complete.
CWD /
250 CWD command successful.
PWD
257 "/" is current directory.
Thank you,
Igor
Hello igor,

Could you try the following and let me know the result?

[scriptftp="test.ftp"]CHDIR("/remotefolder/")

GETLIST($list1,REMOTE_FILES,"*.*")
PRINT("Found ".$list1." files")

GETLIST($list2,REMOTE_FILES,"*")
PRINT("Found ".$list2." files")[/ScriptFTP]
Yes, That worked, but not on the vendor's machine. I actually figured it out as I was trying to list items without changing the directory.
I've setup an SFTP on my side and it's working fine, yet can't do it on the vendor's.

This GETFILE("/out/test/*.pgp") works only if I write out a full file name GETFILE("/out/test/filename.pgp")

Here's the actual script. I have a license for scriptftp, is there a support person I can work with?


[ScriptFTP]VERBOSE (ON)
SETPROTOCOL(FTPS_EXPLICIT_ENCRYPT_DATA)
SETPASSIVE(ENABLED)
SETTYPE(ASCII)

$server="xxxxxxxxxxx"
$username="xxxxx"
$password="xxxxxxx"

# Connect to FTP server-----

$result=OPENHOST($server,$username,$password)

#GET THE FILES-------------

SETCLOCKDIFF(3600)

# Go to local directory

LOCALCHDIR("C:\Concur\scripts\OUT\")

# Get files from Concur's FTP server
CHDIR("/out/test/")

GETLIST($list,REMOTE_FILES,"*.*")

FOREACH $item IN $list
PRINT($item)
END FOREACH

GETFILE("/out/test/*.pgp")

# Transfer finished, close the connection

CLOSEHOST()[/ScriptFTP]
Yes, That worked, but not on the vendor's machine.
Yes, that makes sense. Although the FTP protocol is standard, there are some buggy implementations out there. Particularly with file listings. For example, old windows FTP servers reported file listing as "dos style" file listing but FTP standard uses the "unix style" file listing convention.
is there a support person I can work with?
Yes, of course. Send an email to scriptftp@scriptftp.com.