Sysax Product Forums / Sysax FTP Automation / General Discussion / Losing working directory
Posted:  17 Jan 2015 01:29
Evaluating software for use on a simple FTP script in case that matters for this issue.

Every time I download a file I lose the working remote directory so I am forced to issue a CWD every time I get a file?


ftpsetpath local, ~local_path;
ftpsetpath remote, "/";
ftpcustomcmd "CWD 'PFSFNAN.CBC.D04FSSN.'";

enablepasv();
settransfertype(ascii);
setduperules bysize overwrite overwrite overwrite;   

ftpdownload(file, "UNTT", "UNTT.txt");
ftpcustomcmd "CWD 'PFSFNAN.CBC.D04FSSN.'";
ftpdownload(file, "AREAT", "AREAT.txt");
ftpcustomcmd "CWD 'PFSFNAN.CBC.D04FSSN.'";
ftpdownload(file, "PRSNT", "PRSNT.txt");
ftpcustomcmd "CWD 'PFSFNAN.CBC.D04FSSN.'";
ftpdownload(file, "CAST", "CAST.txt");



HERE IS THE LOGFILE SHOWING WHAT I MEAN.



1/16/2015 6:18:36 PM: [   ] Local  path: E:\asdf
1/16/2015 6:18:36 PM: [   ] Script Engine: Line 27: Executing ftpsetpath. Parameter(s):  remote  "/"
1/16/2015 6:18:36 PM: [CMD] CWD /
1/16/2015 6:18:36 PM: [RSP] 250 HFS directory / is the current working directory
1/16/2015 6:18:36 PM: [CMD] PWD
1/16/2015 6:18:36 PM: [RSP] 257 "/" is the HFS working directory.
1/16/2015 6:18:36 PM: [   ] Remote path: /
1/16/2015 6:18:36 PM: [   ] Script Engine: Line 29: Executing ftpcustomcmd. Parameter(s):  "CWD 'PFSFNAN.CBC.D04FSSN.'"
1/16/2015 6:18:36 PM: [CMD] CWD 'PFSFNAN.CBC.D04FSSN.'
1/16/2015 6:18:36 PM: [RSP] 250 "PFSFNAN.CBC.D04FSSN." is the working directory name prefix.
1/16/2015 6:18:36 PM: [   ] Script Engine: Line 30: Executing enablepasv
1/16/2015 6:18:36 PM: [   ] Script Engine: Line 31: Executing settransfertype. Parameter(s):  ascii
1/16/2015 6:18:36 PM: [   ] Script Engine: Line 32: Executing setduperules. Parameter(s):  bysize  overwrite  overwrite  overwrite
1/16/2015 6:18:36 PM: [   ] Script Engine: Line 38: Executing ftpdownload. Parameter(s):  file  "UNTT"  "UNTT.txt"
1/16/2015 6:18:36 PM: [CMD] MDTM UNTT
1/16/2015 6:18:36 PM: [RSP] 501 command aborted -- FTP server not configured for MDTM
1/16/2015 6:18:36 PM: [WRN] Could not obtain the last modification time for remote file
1/16/2015 6:18:36 PM: [CMD] TYPE I
1/16/2015 6:18:36 PM: [RSP] 200 Representation type is Image
1/16/2015 6:18:36 PM: [CMD] SIZE UNTT
1/16/2015 6:18:36 PM: [RSP] 501 command aborted -- FTP server not configured for SIZE
1/16/2015 6:18:36 PM: [WRN] Could not obtain the size of the remote file
1/16/2015 6:18:36 PM: [CMD] TYPE A
1/16/2015 6:18:36 PM: [RSP] 200 Representation type is Ascii NonPrint
1/16/2015 6:18:36 PM: [CMD] PASV
1/16/2015 6:18:36 PM: [RSP] 227 Entering Passive Mode (160,131,91,9,234,117)
1/16/2015 6:18:36 PM: [CMD] RETR UNTT
1/16/2015 6:18:36 PM: [RSP] 125 Sending data set PFSFNAN.CBC.D04FSSN.UNTT
1/16/2015 6:18:37 PM: [RSP] 250 Transfer completed successfully.
1/16/2015 6:18:37 PM: [CMD] CWD /
1/16/2015 6:18:37 PM: [RSP] 250 HFS directory / is the current working directory
1/16/2015 6:18:37 PM: [CMD] PWD
1/16/2015 6:18:37 PM: [RSP] 257 "/" is the HFS working directory.
1/16/2015 6:18:37 PM: [   ] Script Engine: Line 39: Executing ftpcustomcmd. Parameter(s):  "CWD 'PFSFNAN.CBC.D04FSSN.'"
1/16/2015 6:18:37 PM: [CMD] CWD 'PFSFNAN.CBC.D04FSSN.'
1/16/2015 6:18:37 PM: [RSP] 250 "PFSFNAN.CBC.D04FSSN." is the working directory name prefix.
1/16/2015 6:18:37 PM: [   ] Script Engine: Line 40: Executing ftpdownload. Parameter(s):  file  "AREAT"  "AREAT.txt"
1/16/2015 6:18:37 PM: [CMD] MDTM AREAT
1/16/2015 6:18:37 PM: [RSP] 501 command aborted -- FTP server not configured for MDTM
1/16/2015 6:18:37 PM: [WRN] Could not obtain the last modification time for remote file
1/16/2015 6:18:37 PM: [CMD] TYPE I
1/16/2015 6:18:37 PM: [RSP] 200 Representation type is Image
1/16/2015 6:18:37 PM: [CMD] SIZE AREAT
1/16/2015 6:18:37 PM: [RSP] 501 command aborted -- FTP server not configured for SIZE
1/16/2015 6:18:37 PM: [WRN] Could not obtain the size of the remote file
1/16/2015 6:18:37 PM: [CMD] TYPE A
1/16/2015 6:18:37 PM: [RSP] 200 Representation type is Ascii NonPrint
1/16/2015 6:18:37 PM: [CMD] PASV
1/16/2015 6:18:38 PM: [RSP] 227 Entering Passive Mode (160,131,91,9,234,133)
1/16/2015 6:18:38 PM: [CMD] RETR AREAT
1/16/2015 6:18:38 PM: [RSP] 125 Sending data set PFSFNAN.CBC.D04FSSN.AREAT
1/16/2015 6:18:38 PM: [RSP] 250 Transfer completed successfully.
1/16/2015 6:18:38 PM: [CMD] CWD /
1/16/2015 6:18:38 PM: [RSP] 250 HFS directory / is the current working directory
1/16/2015 6:18:38 PM: [CMD] PWD
1/16/2015 6:18:38 PM: [RSP] 257 "/" is the HFS working directory.
1/16/2015 6:18:38 PM: [   ] Script Engine: Line 41: Executing ftpcustomcmd. Parameter(s):  "CWD 'PFSFNAN.CBC.D04FSSN.'"
1/16/2015 6:18:38 PM: [CMD] CWD 'PFSFNAN.CBC.D04FSSN.'
1/16/2015 6:18:38 PM: [RSP] 250 "PFSFNAN.CBC.D04FSSN." is the working directory name prefix.
Posted:  19 Jan 2015 14:46
Hi bobg,

Please try this:

If you could change the the second line that I see, which is ftpsetpath remote, "/"; to ftpsetpath remote, "/PFSFNAN.CBC.D04FSSN."; then you could comment out with a # all of the lines that start with the word ftpcustomcmd.

Here is a sample script that worked for me:

setvar ~server_address, "john-pc";
setvar ~server_port, 21;
setvar ~login_name, "john";
setvar ~login_password, "password";
setvar ~local_path, "D:\\Temp";
setvar ~remote_path, "/PFSFNAN.CBC.D04FSSN.";

setduperules bysize overwrite overwrite overwrite;

ftpconnect ~server_address, ~server_port, ~login_name, ~login_password;

if ftpresult eq success begin
  # Successfully connected to remote server
  stringjoin ~connect_success_message,  "Successfully connected to remote server at ", ~server_address, " on port ", ~server_port, " for user ", ~login_name;
  print ~connect_success_message;

  ftpsetpath local, ~local_path;
  ftpsetpath remote, ~remote_path;
  #ftpcustomcmd "CWD PFSFNAN.CBC.D04FSSN.";
  enablepasv();
  settransfertype(ascii);
  ftpdownload file, "UNTT.txt";
  ftpdownload file, "AREAT.txt";
  ftpdownload file, "PRSNT.txt";
  ftpdownload file, "CAST.txt";

IF you need further help, please file a ticket at https://www.sysax.com/support/ and we can work with you personally.

Regards,
Sysax support
 

Copyright © 2021 Codeorigin, LLC - All Rights Reserved.
XML RSS 2.0 XML Atom 1.0