BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
senu188
Quartz | Level 8

Hi,

 

I need to connect  to FTP with different port. Can you help on it?

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
I modified your subject line to be more descriptive. Please include a descriptive subject line in future messages.

View solution in original post

12 REPLIES 12
PaigeMiller
Diamond | Level 26

Please help us all out. Go back and edit your post to have a meaningful title that actually describes the problem. A title of "SAS" could apply to every post here, and so should not be used. A post named SAS makes the SAS Communities less useful to everyone.

--
Paige Miller
CurtisMackWSIPP
Lapis Lazuli | Level 10

We are going to need more information.  What tool are you using?  The FTP libname engine has a PORT option that I know works.

senu188
Quartz | Level 8
Hi,

SAS Enterprise guide. we have alreday defined an macro, but without port number . I have defined the port number , but it is not connecting . It says below error.

Stderr output:

Transfers files to and from a computer running an FTP server service
(sometimes called a daemon). Ftp can be used interactively.

FTP [-v] [-d] [-i] [-n] [-g] [-s:filename] [-a] [-A] [-x:sendbuffer] [-r:recvbuffer]
[-b:asyncbuffers] [-w:windowsize] [host]

-v Suppresses display of remote server responses.
-n Suppresses auto-login upon initial connection.
-i Turns off interactive prompting during multiple file
transfers.
-d Enables debugging.
-g Disables filename globbing (see GLOB command).
-s:filename Specifies a text file containing FTP commands; the
commands will automatically run after FTP starts.
-a Use any local interface when binding data connection.
-A login as anonymous.
-x:send sockbuf Overrides the default SO_SNDBUF size of 8192.
-r:recv sockbuf Overrides the default SO_RCVBUF size of 8192.
-b:async count Overrides the default async count of 3
-w:windowsize Overrides the default transfer buffer size of 65535.
host Specifies the host name or IP address of the remote
host to connect to.

Notes:
- mget and mput commands take y/n/q for yes/no/quit.
- Use Control-C to abort commands.
NOTE: 0 records were read from the infile DOFTP.
NOTE: DATA statement used (Total process time):
real time 0.06 seconds
cpu time 0.03 seconds

CurtisMackWSIPP
Lapis Lazuli | Level 10

We will need to see some code.  This error looks like you are getting an FTP manual page.  I doubt you will be able to change the port without getting into the code of that macro you are using.

senu188
Quartz | Level 8
Ok sure.

%LET FTPCMDS=\\neovia.prv\..................test.txt;

%LET HOST1=.......;
%LET PORT=.......;

%LET USERID ='.......';
%LET PASSWORD ='.........'; /* TEST SYSTEM USER */


%macro XFERFILESTONAS1(lfile,rfile,SYSTEM);

filename ftpcmds "&ftpcmds"; /* Libref to execute the ftp command */

data _null_;
file ftpcmds pad lrecl=326;
put 'open ' "&host1" ' ' "&port" ;
put 'user ' &USERID ' ' &PASSWORD ; /* UserID and Password */
put 'cd "/Ford_MMP/outbox"'; /* the files reside in the */
put 'lcd "' &rfile '"';
put 'get "' &lfile '"';
put 'close';
put 'quit'; /* End of FTP commands */
put 'debug';
run;

%IF &SYSTEM='PROD' %THEN %DO;
filename doftp pipe "ftp -n -s:&ftpcmds &host1 &port"; /* FTP Command File */
run;
%END;

/* Invoke FTP transfer */
data _null_;
infile doftp;
input;
put _infile_;
run;
%mend XFERFILESTONAS1;


%XFERFILESTONAS1('......txt','\\NEOVIA.PRV....................','......');
CurtisMackWSIPP
Lapis Lazuli | Level 10

This is an old approach to using FTP in SAS.  I would recommend you look into the FTP libname engine.

 

That said, this code is generating an script for an FTP client, shelling out, and executing the FTP command with that script.  

I am pretty sure you don't want the port in this line.  It should stay on the open statement where you already have it.  I think you also don't want the host in that line either since you have an open command in the script.

 

filename doftp pipe "ftp -n -s:&ftpcmds &host1 &port"; /* FTP Command File */

Try this instead.

 

filename doftp pipe "ftp -n -s:&ftpcmds "; /* FTP Command File */
senu188
Quartz | Level 8
Hi,
I tried it, it is running , it is not stoping at all.
CurtisMackWSIPP
Lapis Lazuli | Level 10
Does this mean it is working, or now it is just hanging? It it worked, please mark the accepted solution.
senu188
Quartz | Level 8
Its hanging
CurtisMackWSIPP
Lapis Lazuli | Level 10

You should see the FTP dialog in your SAS log window.  It should help you figure out why.

senu188
Quartz | Level 8
Hi,

Nothing is happening . It is writing something else . No use at all. When i saw the text file after running macro the information with ip and port is correct. I think if the below format comes in text file for sas, it will work.

Text File after macro.

open .......Ip ........port
user ......username .......password
cd ".... path FTP"
lcd "\\NEOVIA.PRV\............."
get "...........txt"
close
quit
debug

Format looking in sas . I checked in CMD it is working with below format

C:\Users\username>ftp
ftp> open ..... Ip address ....port
Reeza
Super User
I modified your subject line to be more descriptive. Please include a descriptive subject line in future messages.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 12 replies
  • 1129 views
  • 1 like
  • 4 in conversation