DATA Step, Macro, Functions and more

Upload csv file to ftp site

Reply
Occasional Contributor
Posts: 18

Upload csv file to ftp site

Hi All

We have a batch process that uploads a number of files from a Unix server to an ftp site. Recently the ftp site (which is a windows server), ran out of space during the process and around 10 files were not ftp-ed. Our problem is that it is not logged as a failure in SAS, and therefore we had no visibility of the problem. Is there an option that should be added to the code below to cause failure?

 

Code submitted:

filename ftpcmds "/sas/batch/sascode/models/ftp/ftp.cmd";

data _null_;
file ftpcmds pad lrecl=80;
put "user &sasbatchuser &sasbatchpass";
put "ascii";
put "lcd /sas/batch/sascode/models/export";
put "cd SAS_IMPORT";
put "put model_&model_id._&output_date..csv";
put "bye";
run;

filename doftp pipe "ftp -n &EDWGW < /sas/batch/sascode/models/ftp/ftp.cmd";
data _null_;
infile doftp;
input;
put _infile_;
run;

 

SAS log:

SYMBOLGEN: Macro variable EDWGW resolves to prd-edwgw01
MPRINT(APPLY_MODEL): filename doftp pipe "ftp -n prd-edwgw01 <
/sas/batch/sascode/models/ftp/ftp.cmd";
MPRINT(APPLY_MODEL): data _null_;
MPRINT(APPLY_MODEL): infile doftp;
MPRINT(APPLY_MODEL): input;
MPRINT(APPLY_MODEL): put _infile_;
MPRINT(APPLY_MODEL): run;

NOTE: The infile DOFTP is:
Pipe command="ftp -n prd-edwgw01 < /sas/batch/sascode/models/ftp/ftp.cmd"

Local directory now /sas/batch/sascode/models/export
There is not enough space on the disk.
Command not understood.

Super User
Posts: 7,758

Re: Upload csv file to ftp site

[ Edited ]

Try a redirection of stderr to stdout:

filename doftp pipe "ftp -n &EDWGW < /sas/batch/sascode/models/ftp/ftp.cmd 2>&1";
data _null_;
infile doftp;
input;
put _infile_;
run;

and then look what you get in the log when you force an out-of-space condition. This might enable you to scan for the relevant text snippet and do a conditional abort abend or the like.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 7,758

Re: Upload csv file to ftp site

PS if the files were originally written from SAS, you might consider to use filename ftp and write the files directly to the FTP server. That way, SAS will catch the disk full condition.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 18

Re: Upload csv file to ftp site

Posted in reply to KurtBremser

Thanks @KurtBremser! Busy trying that out as we speak Smiley Happy

Ask a Question
Discussion stats
  • 3 replies
  • 130 views
  • 0 likes
  • 2 in conversation