<?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: Running Unix scripts/commands from SAS programs in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Running-Unix-scripts-commands-from-SAS-programs/m-p/497401#M131824</link>
    <description>&lt;P&gt;Here is an example of Linux shell&amp;nbsp;script used to sftp files created by a SAS program &lt;img id="robotvery-happy" class="emoticon emoticon-robotvery-happy" src="https://communities.sas.com/i/smilies/16x16_robot-very-happy.png" alt="Robot Very Happy" title="Robot Very Happy" /&gt;:&lt;/P&gt;&lt;P&gt;#!/bin/sh&lt;/P&gt;&lt;P&gt;echo "Ok, starting now..."&lt;/P&gt;&lt;P&gt;# You must put the system paths ahead of the paths added for SAS to include some cryptographic libraries&lt;/P&gt;&lt;P&gt;LD_LIBRARY_PATH=/usr/lib64:/lib64: $LD_LIBRARY_PATH&lt;/P&gt;&lt;P&gt;export LD_LIBRARY_PATH&lt;/P&gt;&lt;P&gt;sftp YOURUSER@SFTPSERVER &amp;lt;&amp;lt; EOF&lt;/P&gt;&lt;P&gt;# Transfer all files using mput&lt;/P&gt;&lt;P&gt;mput /YOUR FOLDER ON SFTP SERVER/*&lt;/P&gt;&lt;P&gt;bye&lt;/P&gt;&lt;P&gt;In the corresponding SAS script you'd call it:&lt;/P&gt;&lt;DIV&gt;filename oscmd pipe "/FOLDER/SHELL_SCRIPT.sh 2&amp;gt;&amp;amp;1";&lt;/DIV&gt;&lt;DIV&gt;data _null_;&lt;/DIV&gt;&lt;DIV&gt;infile oscmd;&lt;/DIV&gt;&lt;DIV&gt;input;&lt;/DIV&gt;&lt;DIV&gt;put _infile_;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;filename oscmd clear;&lt;/DIV&gt;</description>
    <pubDate>Thu, 20 Sep 2018 14:44:55 GMT</pubDate>
    <dc:creator>mich1</dc:creator>
    <dc:date>2018-09-20T14:44:55Z</dc:date>
    <item>
      <title>Running Unix scripts/commands from SAS programs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Unix-scripts-commands-from-SAS-programs/m-p/75999#M16398</link>
      <description>Hi,&lt;BR /&gt;
I am trying to accomplish a simple task using SAS &amp;amp; Unix server-&lt;BR /&gt;
i) Create a shell script in a particular Unix directory which will have FTP commands&lt;BR /&gt;
ii) Run this shell script from SAS to transfer the required files from server1 to server2.&lt;BR /&gt;
&lt;BR /&gt;
Step i) is easily done using a data step+file statement+ put statements.&lt;BR /&gt;
Stepii) is not working and I have tried 3 different ways -&lt;BR /&gt;
a) X command&lt;BR /&gt;
X  'sh /SASInt/.../ftp_script.sh &amp;amp;';&lt;BR /&gt;
b) %macro sample;&lt;BR /&gt;
%sysexec %str(sh /SASInt/.../ftp_script.sh &amp;amp;)'&lt;BR /&gt;
c) filename results pipe "sh /SASInt/.../ftp_script.ksh &amp;amp;";&lt;BR /&gt;
&lt;BR /&gt;
Even if I change the permissions to 777 for ftp_script.sh, it does not work.&lt;BR /&gt;
&lt;BR /&gt;
Does anyone have suggestions?&lt;BR /&gt;
&lt;BR /&gt;
Thanks.</description>
      <pubDate>Thu, 15 Oct 2009 21:41:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Unix-scripts-commands-from-SAS-programs/m-p/75999#M16398</guid>
      <dc:creator>saspert</dc:creator>
      <dc:date>2009-10-15T21:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: Running Unix scripts/commands from SAS programs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Unix-scripts-commands-from-SAS-programs/m-p/76000#M16399</link>
      <description>What exactly is not working? What error do you get?&lt;BR /&gt;
&lt;BR /&gt;
Can you execute your sh script from a command line window?&lt;BR /&gt;
&lt;BR /&gt;
Is sh the default shell? You could give %systask a try as there you can explicitly define the shell.</description>
      <pubDate>Thu, 15 Oct 2009 21:54:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Unix-scripts-commands-from-SAS-programs/m-p/76000#M16399</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2009-10-15T21:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: Running Unix scripts/commands from SAS programs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Unix-scripts-commands-from-SAS-programs/m-p/76001#M16400</link>
      <description>Should work, nothing wrong with both methods you described.&lt;BR /&gt;
&lt;BR /&gt;
Please give us more info about the error.&lt;BR /&gt;
&lt;BR /&gt;
Cheers from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;.</description>
      <pubDate>Fri, 16 Oct 2009 10:56:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Unix-scripts-commands-from-SAS-programs/m-p/76001#M16400</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2009-10-16T10:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: Running Unix scripts/commands from SAS programs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Unix-scripts-commands-from-SAS-programs/m-p/76002#M16401</link>
      <description>I suspect that the final task might be to read these files using SAS?&lt;BR /&gt;
 If this is the case you could give FILENAME FTP a try.&lt;BR /&gt;
&lt;BR /&gt;
/Linus</description>
      <pubDate>Fri, 16 Oct 2009 12:49:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Unix-scripts-commands-from-SAS-programs/m-p/76002#M16401</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2009-10-16T12:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: Running Unix scripts/commands from SAS programs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Unix-scripts-commands-from-SAS-programs/m-p/76003#M16402</link>
      <description>Hi guys,&lt;BR /&gt;
I will reply to your questions -&lt;BR /&gt;
Patrick:&lt;BR /&gt;
1. It does not throw any errors. The log file shows it as executed but I dont see the file being transferred from server1 to server2. So, that means the ftp commands inside the shell script have not worked.&lt;BR /&gt;
2.yes. I can execute this shell script from my unix command line. It works perfect.&lt;BR /&gt;
3.I believe korn shell is the default shell. We also have bourne shell but I think the shell need not be changed?&lt;BR /&gt;
Linus:&lt;BR /&gt;
The final objective is to move text file/raw files from server1 to server2 where our group's SAS tools/instances are installed.&lt;BR /&gt;
&lt;BR /&gt;
11         ODS HTML(ID=EGHTML) FILE=EGHTML ENCODING='utf-8' STYLE=EGDefault&lt;BR /&gt;
11       ! STYLESHEET=(URL="file:///C:/Program%20Files/SAS/Shared%20Files/BIClientStyles/EGDefault.css")&lt;BR /&gt;
11       ! ATTRIBUTES=("CODEBASE"="http://www2.sas.com/codebase/graph/v91/sasgraph.exe") NOGTITLE NOGFOOTNOTE GPATH=&amp;amp;sasworklocation&lt;BR /&gt;
11       ! ;&lt;BR /&gt;
12         &lt;BR /&gt;
13         %gaccessible;&lt;BR /&gt;
14         X 'sh /SASInt/...../ftp_script.sh &amp;amp;'&lt;BR /&gt;
14       !                                                                      ;&lt;BR /&gt;
15         &lt;BR /&gt;
16         &lt;BR /&gt;
17         %LET _CLIENTTASKLABEL=;&lt;BR /&gt;
18         %LET _EGTASKLABEL=;&lt;BR /&gt;
                                                        ;&lt;BR /&gt;
&lt;BR /&gt;
The lines 11-13 and 15-18 are EG specific. They appear for all the codes executed in my EG. So,we can ignore them.&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Raj.</description>
      <pubDate>Fri, 16 Oct 2009 14:22:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Unix-scripts-commands-from-SAS-programs/m-p/76003#M16402</guid>
      <dc:creator>saspert</dc:creator>
      <dc:date>2009-10-16T14:22:47Z</dc:date>
    </item>
    <item>
      <title>Re: Running Unix scripts/commands from SAS programs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Unix-scripts-commands-from-SAS-programs/m-p/76004#M16403</link>
      <description>could it be that your working directory on the unix server (usually your /home) is different from the 'working directory' for the SAS program, which is defaulted to where the software is installed?</description>
      <pubDate>Fri, 16 Oct 2009 14:42:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Unix-scripts-commands-from-SAS-programs/m-p/76004#M16403</guid>
      <dc:creator>abdullala</dc:creator>
      <dc:date>2009-10-16T14:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: Running Unix scripts/commands from SAS programs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Unix-scripts-commands-from-SAS-programs/m-p/76005#M16404</link>
      <description>I think abdullala is on the right track.  You gave the complete pathname of the script you wish to run; so, it runs.  However, the working directory of the shell is the working directory SAS uses.&lt;BR /&gt;
If the SAS working directory in not your home directory, and if the ftp commands in your script file do not give the complete pathnames of the files you wish to transfer, then the ftp process will not find the files.  However, when you ran the script from the command line the current working directory was your home directory; hence, the files were found and the script succeeded.&lt;BR /&gt;
Solutions: &lt;BR /&gt;
1) put the complete pathnames of the files into your script.&lt;BR /&gt;
2) put a cd command to your home directory (cd ~) into your SAS X command.</description>
      <pubDate>Wed, 28 Oct 2009 19:07:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Unix-scripts-commands-from-SAS-programs/m-p/76005#M16404</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-10-28T19:07:23Z</dc:date>
    </item>
    <item>
      <title>Re: Running Unix scripts/commands from SAS programs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Unix-scripts-commands-from-SAS-programs/m-p/76006#M16405</link>
      <description>Hi:&lt;BR /&gt;
  Usually the X command is disabled for EG clients. It might be that your SAS administrators have done this at your installation. See these Tech Support Notes:&lt;BR /&gt;
&lt;A href="http://support.sas.com/kb/16/405.html" target="_blank"&gt;http://support.sas.com/kb/16/405.html&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://support.sas.com/kb/4/503.html" target="_blank"&gt;http://support.sas.com/kb/4/503.html&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
cynthia</description>
      <pubDate>Wed, 28 Oct 2009 20:51:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Unix-scripts-commands-from-SAS-programs/m-p/76006#M16405</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-10-28T20:51:16Z</dc:date>
    </item>
    <item>
      <title>Re: Running Unix scripts/commands from SAS programs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Unix-scripts-commands-from-SAS-programs/m-p/76007#M16406</link>
      <description>what is the option XCMD value. If XCMD = NOXCMD, then you can not run X command.&lt;BR /&gt;
Simplest way to do check:&lt;BR /&gt;
proc options &lt;BR /&gt;
	option=XCMD;&lt;BR /&gt;
quit;</description>
      <pubDate>Mon, 02 Nov 2009 09:29:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Unix-scripts-commands-from-SAS-programs/m-p/76007#M16406</guid>
      <dc:creator>SAS_user</dc:creator>
      <dc:date>2009-11-02T09:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: Running Unix scripts/commands from SAS programs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Unix-scripts-commands-from-SAS-programs/m-p/497401#M131824</link>
      <description>&lt;P&gt;Here is an example of Linux shell&amp;nbsp;script used to sftp files created by a SAS program &lt;img id="robotvery-happy" class="emoticon emoticon-robotvery-happy" src="https://communities.sas.com/i/smilies/16x16_robot-very-happy.png" alt="Robot Very Happy" title="Robot Very Happy" /&gt;:&lt;/P&gt;&lt;P&gt;#!/bin/sh&lt;/P&gt;&lt;P&gt;echo "Ok, starting now..."&lt;/P&gt;&lt;P&gt;# You must put the system paths ahead of the paths added for SAS to include some cryptographic libraries&lt;/P&gt;&lt;P&gt;LD_LIBRARY_PATH=/usr/lib64:/lib64: $LD_LIBRARY_PATH&lt;/P&gt;&lt;P&gt;export LD_LIBRARY_PATH&lt;/P&gt;&lt;P&gt;sftp YOURUSER@SFTPSERVER &amp;lt;&amp;lt; EOF&lt;/P&gt;&lt;P&gt;# Transfer all files using mput&lt;/P&gt;&lt;P&gt;mput /YOUR FOLDER ON SFTP SERVER/*&lt;/P&gt;&lt;P&gt;bye&lt;/P&gt;&lt;P&gt;In the corresponding SAS script you'd call it:&lt;/P&gt;&lt;DIV&gt;filename oscmd pipe "/FOLDER/SHELL_SCRIPT.sh 2&amp;gt;&amp;amp;1";&lt;/DIV&gt;&lt;DIV&gt;data _null_;&lt;/DIV&gt;&lt;DIV&gt;infile oscmd;&lt;/DIV&gt;&lt;DIV&gt;input;&lt;/DIV&gt;&lt;DIV&gt;put _infile_;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;filename oscmd clear;&lt;/DIV&gt;</description>
      <pubDate>Thu, 20 Sep 2018 14:44:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Unix-scripts-commands-from-SAS-programs/m-p/497401#M131824</guid>
      <dc:creator>mich1</dc:creator>
      <dc:date>2018-09-20T14:44:55Z</dc:date>
    </item>
  </channel>
</rss>

