<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: FTP connections fails, how to define this? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/FTP-connections-fails-how-to-define-this/m-p/40753#M8337</link>
    <description>Not sure if this will aide you since i do not have a ftp with which to verify but you could try to use fileref function:&lt;BR /&gt;
&lt;BR /&gt;
%macro check_ftp_connection(inf=);&lt;BR /&gt;
 %if %sysfunc(fileref(&amp;amp;inf)) ne 0 %then&lt;BR /&gt;
  %put %sysfunc(sysmsg());&lt;BR /&gt;
%mend;&lt;BR /&gt;
&lt;BR /&gt;
filename indir ftp user='user' pass='pass' host='host' dir;&lt;BR /&gt;
&lt;BR /&gt;
%check_ftp_connection(inf=indir);&lt;BR /&gt;
&lt;BR /&gt;
Since you said it is not generating a error I am not sure that this will benefit.

Message was edited by: Fried Egg</description>
    <pubDate>Wed, 30 Mar 2011 16:20:59 GMT</pubDate>
    <dc:creator>FriedEgg</dc:creator>
    <dc:date>2011-03-30T16:20:59Z</dc:date>
    <item>
      <title>FTP connections fails, how to define this?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/FTP-connections-fails-how-to-define-this/m-p/40752#M8336</link>
      <description>Hi All,&lt;BR /&gt;
So I use standard FTP connections for accessing to remote files:&lt;BR /&gt;
Smth. like this:&lt;BR /&gt;
&lt;BR /&gt;
filename indir ftp '' user='username' pass='xxxx' host='yyyy' DIR;&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
   infile indir;&lt;BR /&gt;
   input;&lt;BR /&gt;
   %put _infile_;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Sometimes connections fails and notes  throws to the log:&lt;BR /&gt;
NOTE: &amp;lt;&amp;lt;&amp;lt; 421 Service not available, closing control connection.&lt;BR /&gt;
&lt;BR /&gt;
So can I somehow indicate if such situations happens(if connections fails)?&lt;BR /&gt;
I tried to compare global macro vars which creates if such situation  occur with gl. macro vars which creates if file loaded successfully, but looks like they are the same.&lt;BR /&gt;
May be the only one way is to get target file size, if it 0 then attempt is not successful, but must be some more clever and simple way to resolve this problem.&lt;BR /&gt;
So how can I know that ftp connections were finished successfully?&lt;BR /&gt;
&lt;BR /&gt;
Thanks!</description>
      <pubDate>Wed, 30 Mar 2011 14:51:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/FTP-connections-fails-how-to-define-this/m-p/40752#M8336</guid>
      <dc:creator>Yura2301</dc:creator>
      <dc:date>2011-03-30T14:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: FTP connections fails, how to define this?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/FTP-connections-fails-how-to-define-this/m-p/40753#M8337</link>
      <description>Not sure if this will aide you since i do not have a ftp with which to verify but you could try to use fileref function:&lt;BR /&gt;
&lt;BR /&gt;
%macro check_ftp_connection(inf=);&lt;BR /&gt;
 %if %sysfunc(fileref(&amp;amp;inf)) ne 0 %then&lt;BR /&gt;
  %put %sysfunc(sysmsg());&lt;BR /&gt;
%mend;&lt;BR /&gt;
&lt;BR /&gt;
filename indir ftp user='user' pass='pass' host='host' dir;&lt;BR /&gt;
&lt;BR /&gt;
%check_ftp_connection(inf=indir);&lt;BR /&gt;
&lt;BR /&gt;
Since you said it is not generating a error I am not sure that this will benefit.

Message was edited by: Fried Egg</description>
      <pubDate>Wed, 30 Mar 2011 16:20:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/FTP-connections-fails-how-to-define-this/m-p/40753#M8337</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2011-03-30T16:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: FTP connections fails, how to define this?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/FTP-connections-fails-how-to-define-this/m-p/40754#M8338</link>
      <description>Thanks Fried!&lt;BR /&gt;
But the file creates just with 0 length, so such functionality isn't suitible.&lt;BR /&gt;
&lt;BR /&gt;
I rid of this problem by using such code:&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
  infile indir(filename);&lt;BR /&gt;
  input;&lt;BR /&gt;
  a='0';&lt;BR /&gt;
  %put _infile_;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
If record_count&amp;gt;0 then %put ok %else %put error;&lt;BR /&gt;
&lt;BR /&gt;
But I still think that must be some better solution. &lt;BR /&gt;
&lt;BR /&gt;
Anyway thanks!</description>
      <pubDate>Thu, 31 Mar 2011 06:33:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/FTP-connections-fails-how-to-define-this/m-p/40754#M8338</guid>
      <dc:creator>Yura2301</dc:creator>
      <dc:date>2011-03-31T06:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: FTP connections fails, how to define this?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/FTP-connections-fails-how-to-define-this/m-p/40755#M8339</link>
      <description>You need a auto macro variable to check the status of filename statement.&lt;BR /&gt;
[pre]&lt;BR /&gt;
filename indir ftp '' user='username' pass='xxxx' host='yyyy' DIR;&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
infile indir;&lt;BR /&gt;
input;&lt;BR /&gt;
%put _infile_;&lt;BR /&gt;
%put return code of filename statement : &lt;B&gt;&amp;amp;sysfilrc &lt;/B&gt;;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Wed, 06 Apr 2011 09:13:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/FTP-connections-fails-how-to-define-this/m-p/40755#M8339</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-04-06T09:13:59Z</dc:date>
    </item>
  </channel>
</rss>

