- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I need to connect to FTP with different port. Can you help on it?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
We are going to need more information. What tool are you using? The FTP libname engine has a PORT option that I know works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
%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....................','......');
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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 */
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I tried it, it is running , it is not stoping at all.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You should see the FTP dialog in your SAS log window. It should help you figure out why.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content