<?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: filename function with user, password on linux in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/filename-function-with-user-password-on-linux/m-p/236914#M43422</link>
    <description>&lt;P&gt;According to documentation&amp;nbsp;&lt;A href="https://support.sas.com/documentation/cdl/en/hostunx/61879/HTML/default/viewer.htm#a000195127.htm" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/hostunx/61879/HTML/default/viewer.htm#a000195127.htm&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;the valid syntax for the filename function is:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;FILENAME(fileref, filename &amp;lt;,device-type&amp;lt;,"host-options"&amp;lt;,dir-ref&amp;gt;&amp;gt;&amp;gt;)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to this syntax (and also the example given in the docu link) you need to single quote the credential bits.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;rc = filename(fref, DISK, "/project/anotherproject/src/file_I_want_to_access.txt", 
     'USER="xyz"', 'PASS="{SAS002}3427979DHKS79237SDHH323"');   &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What I'm not so sure about: Can you use a SAS encoded password this way? You need to try. I have my doubts that it will work but curious what you will tell us.&lt;/P&gt;</description>
    <pubDate>Mon, 30 Nov 2015 10:40:00 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2015-11-30T10:40:00Z</dc:date>
    <item>
      <title>filename function with user, password on linux</title>
      <link>https://communities.sas.com/t5/SAS-Programming/filename-function-with-user-password-on-linux/m-p/236911#M43421</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My SAS program runs on a linux server. I need to access files in a directory that my user (abc) cannot acces due to user rights. So I use another user (xyz) that has read rights on the directory:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename fref FTP "/project/anotherprpject/src/file_I_want_to_access.txt" 
USER = "xyz" PASS = "{SAS002}3427979DHKS79237SDHH323";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This works.&lt;/P&gt;
&lt;P&gt;[Note: if I use DISK instead of FTP as device the statement does not work, because DISK does not allow the option USER]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now. I'd like to do the same with the filename &lt;STRONG&gt;function&lt;/STRONG&gt;. Can anybody give my the right syntax? Seems like I'm getting the '&amp;nbsp; , " etc. wrong.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _null_;   
     length fref $8 filename $80;     
     rc = filename("fref", "/project/anotherproject/src/file_I_want_to_access.txt", "ftp",
     'USER = "xyz", PASS = "{SAS002}3427979DHKS79237SDHH323"');    
     if not fexist(fref) then do;         
          call symput ("l_sErrMsg", "file does not exist.");             
          call symput ("l_nErrRC", "-1");         
          return;        
     end;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This doesn't work. I get the error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;Message:ERROR: Invalid option name ,.&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best wishes&lt;/P&gt;
&lt;P&gt;Eva&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2015 10:42:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/filename-function-with-user-password-on-linux/m-p/236911#M43421</guid>
      <dc:creator>Eva</dc:creator>
      <dc:date>2015-11-30T10:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: filename function with user, password on linux</title>
      <link>https://communities.sas.com/t5/SAS-Programming/filename-function-with-user-password-on-linux/m-p/236914#M43422</link>
      <description>&lt;P&gt;According to documentation&amp;nbsp;&lt;A href="https://support.sas.com/documentation/cdl/en/hostunx/61879/HTML/default/viewer.htm#a000195127.htm" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/hostunx/61879/HTML/default/viewer.htm#a000195127.htm&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;the valid syntax for the filename function is:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;FILENAME(fileref, filename &amp;lt;,device-type&amp;lt;,"host-options"&amp;lt;,dir-ref&amp;gt;&amp;gt;&amp;gt;)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to this syntax (and also the example given in the docu link) you need to single quote the credential bits.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;rc = filename(fref, DISK, "/project/anotherproject/src/file_I_want_to_access.txt", 
     'USER="xyz"', 'PASS="{SAS002}3427979DHKS79237SDHH323"');   &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What I'm not so sure about: Can you use a SAS encoded password this way? You need to try. I have my doubts that it will work but curious what you will tell us.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2015 10:40:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/filename-function-with-user-password-on-linux/m-p/236914#M43422</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-11-30T10:40:00Z</dc:date>
    </item>
    <item>
      <title>Re: filename function with user, password on linux</title>
      <link>https://communities.sas.com/t5/SAS-Programming/filename-function-with-user-password-on-linux/m-p/236916#M43423</link>
      <description>&lt;P&gt;Dear Patrick,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;meanwhile I found out, that DISK doesn't allow user and password (I edited this in my orginal post). So I use ftp as described in the documentation for UNIX and filename function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I tried this with your example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;rc = filename (fref, FTP, "/project/anotherproject/src/file_I_want_to_access.txt, 
'user="xyz"',
'pass="{SAS002}3427979DHKS79237SDHH323"');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I tried this after I read the documentation and followed the adivice there (changed filename and device in order; set fref and ftp in quotation marks):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;rc = filename ("fref", "/project/anotherproject/src/file_I_want_to_access.txt, 
"ftp",
'user="xyz"',
'pass="{SAS002}3427979DHKS79237SDHH323"');&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In both cases the Error message is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Message:ERROR: Invalid logical name.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2015 10:56:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/filename-function-with-user-password-on-linux/m-p/236916#M43423</guid>
      <dc:creator>Eva</dc:creator>
      <dc:date>2015-11-30T10:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: filename function with user, password on linux</title>
      <link>https://communities.sas.com/t5/SAS-Programming/filename-function-with-user-password-on-linux/m-p/237042#M43438</link>
      <description>&lt;P&gt;Is there a double quote missing after the path/filename?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2015 20:21:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/filename-function-with-user-password-on-linux/m-p/237042#M43438</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-11-30T20:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: filename function with user, password on linux</title>
      <link>https://communities.sas.com/t5/SAS-Programming/filename-function-with-user-password-on-linux/m-p/237110#M43455</link>
      <description>&lt;P&gt;Yes, you're right.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;rc = filename ("fref", "/project/anotherproject/src/file_I_want_to_access.txt", 
"ftp",
'user="xyz"',
'pass="{SAS002}3427979DHKS79237SDHH323"');&lt;/PRE&gt;
&lt;P&gt;and:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;rc = filename ("fref", "/project/anotherproject/src/file_I_want_to_access.txt", 
"ftp",
'user="xyz",
pass="{SAS002}3427979DHKS79237SDHH323"');&lt;/PRE&gt;
&lt;P&gt;and got the message:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Message:ERROR: Invalid logical name.&lt;/PRE&gt;
&lt;P&gt;Then I added the host name:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;rc = filename ("fref", "/project/anotherproject/src/file_I_want_to_access.txt", 
"ftp",
'user="xyz",
host="my.host.name"
pass="{SAS002}3427979DHKS79237SDHH323"');&lt;/PRE&gt;
&lt;P&gt;Added the port number (7551) with a blank and in the second example with a colon:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;rc = filename ("fref", "/project/anotherproject/src/file_I_want_to_access.txt", 
"ftp",
'user="xyz",
host="my.host.name 7551"
pass="{SAS002}3427979DHKS79237SDHH323"');&lt;/PRE&gt;
&lt;PRE&gt;rc = filename ("fref", "/project/anotherproject/src/file_I_want_to_access.txt", 
"ftp",
'user="xyz",
host="my.host.name:7551"
pass="{SAS002}3427979DHKS79237SDHH323"');&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and in all three cases got the message:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ERROR: Invalid option name                     &amp;#8;   &amp;#144;XÌ6Ÿ+  p¥ž&amp;#20;Ÿ+  ðEÀ&amp;#20;Ÿ+   &amp;#2;      &amp;#23;&amp;#16; €    @fÐ6Ÿ+   &amp;#2;      ¦Réåž+  ðEÀ&amp;#20;Ÿ+   &amp;#1;       
       &amp;#2;&amp;#2;       &amp;#1;       UÀ&amp;#20;Ÿ+  &amp;#16;r1&amp;#21;Ÿ+              Ÿ+          0fÐ6Ÿ&lt;/PRE&gt;
&lt;P&gt;I have no more ideas... do you?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Dec 2015 07:36:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/filename-function-with-user-password-on-linux/m-p/237110#M43455</guid>
      <dc:creator>Eva</dc:creator>
      <dc:date>2015-12-01T07:36:43Z</dc:date>
    </item>
    <item>
      <title>Re: filename function with user, password on linux</title>
      <link>https://communities.sas.com/t5/SAS-Programming/filename-function-with-user-password-on-linux/m-p/237242#M43486</link>
      <description>&lt;P&gt;I believe you can't use the SAS encoded password for your FTP connection. Try without encoding (just as a test, not as the final solution).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's go back to your initial problem:&lt;/P&gt;
&lt;P&gt;"&lt;SPAN&gt;&lt;EM&gt;My SAS program runs on a linux server. I need to access files in a directory that my user (abc) cannot acces due to user rights. So I use another user (xyz) that has read rights on the directory&lt;/EM&gt;:&lt;/SPAN&gt;"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The way I normally get my UNIX/Linux commands right: I'm using Putty and try them first via command prompt.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your case: Can you FTP from the same machine? Try first in Putty and only if that works try out of SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe another option is to&amp;nbsp;execute a command with the credentials of another user (elevated priviledges).&lt;/P&gt;
&lt;P&gt;&lt;A href="https://linuxacademy.com/blog/linux/linux-commands-for-beginners-sudo/" target="_blank"&gt;https://linuxacademy.com/blog/linux/linux-commands-for-beginners-sudo/&lt;/A&gt; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I haven't done the following myself so just throwing ideas:&lt;/P&gt;
&lt;P&gt;- Login via Putty with your normal SAS user&lt;/P&gt;
&lt;P&gt;- Issue SUDO to change to the user with access priviledges to your file&lt;/P&gt;
&lt;P&gt;-&amp;nbsp;Test file access (eg. issuing a CAT command for your file)&lt;/P&gt;
&lt;P&gt;- If all of the above works:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; - Use a PIPE:&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &lt;A href="https://support.sas.com/documentation/cdl/en/hostunx/67929/HTML/default/viewer.htm#n1ceb0xedanuj3n19l3g73awk1wf.htm" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/hostunx/67929/HTML/default/viewer.htm#n1ceb0xedanuj3n19l3g73awk1wf.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; Write&amp;nbsp;either a Shell script or&amp;nbsp;combine all commands directly in the command bit of the Filename Pipe syntax.&lt;BR /&gt;&amp;nbsp; &amp;nbsp; (I believe you need just a SUDO and a CAT).&lt;BR /&gt;&amp;nbsp; - Use the fileref in your data step reading the file into SAS&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Much easier would be...&lt;/P&gt;
&lt;P&gt;Get read access for your normal SAS user to this directory and file&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Dec 2015 19:39:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/filename-function-with-user-password-on-linux/m-p/237242#M43486</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-12-01T19:39:07Z</dc:date>
    </item>
  </channel>
</rss>

