<?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: how to send a unix command to a unix server using a pipe command in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-send-a-unix-command-to-a-unix-server-using-a-pipe-command/m-p/916504#M44313</link>
    <description>&lt;PRE class="language-sas"&gt;&lt;CODE&gt;data _null_; 
  set filelisting;
  infile unix pipe filevar=unixcommand end=eof;
  do while (not eof);
    input;
    put _infile_;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;I might be wrong but what I think, is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;set filelisting; is use to select the dataset that I want to use&lt;/P&gt;
&lt;P&gt;do while (not eof);&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;end&lt;/P&gt;
&lt;P&gt;will execute what at in between until the end of the file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;input statement read the file filelisting one record at the time&lt;/P&gt;
&lt;P&gt;which is put into _infile_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;infile unix pipe ????&lt;/P&gt;</description>
    <pubDate>Fri, 16 Feb 2024 16:21:28 GMT</pubDate>
    <dc:creator>alepage</dc:creator>
    <dc:date>2024-02-16T16:21:28Z</dc:date>
    <item>
      <title>how to send a unix command to a unix server using a pipe command</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-send-a-unix-command-to-a-unix-server-using-a-pipe-command/m-p/916437#M44310</link>
      <description>&lt;P&gt;Few days ago, someone from the community propose me the script below to send multiple unix command to our unix server.&lt;/P&gt;
&lt;P&gt;It works well.&amp;nbsp; However the purpose of my request today is could someone explain me in details how does it works because it is not clear in my mind.&lt;/P&gt;
&lt;P&gt;Please note that the filename is filelisting, the variable unixcommand contains the unix commands to be sent to the unix server.&lt;/P&gt;
&lt;P&gt;Could you please explain each step of this piece of code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_; 
  set filelisting;
  infile unix pipe filevar=unixcommand end=eof;
  do while (not eof);
    input;
    put _infile_;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Feb 2024 13:28:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-send-a-unix-command-to-a-unix-server-using-a-pipe-command/m-p/916437#M44310</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2024-02-16T13:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: how to send a unix command to a unix server using a pipe command</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-send-a-unix-command-to-a-unix-server-using-a-pipe-command/m-p/916479#M44312</link>
      <description>&lt;P&gt;Do you know what a PIPE is in Unix?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.geeksforgeeks.org/piping-in-unix-or-linux/" target="_blank"&gt;https://www.geeksforgeeks.org/piping-in-unix-or-linux/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you know what the PIPE file device type is in SAS? Look at FILENAME statement.&lt;/P&gt;
&lt;P&gt;Do you know what the FILEVAR= option of the INFILE statement does?&lt;/P&gt;
&lt;P&gt;Do you know what the END= option of the INFILE statement does?&lt;/P&gt;
&lt;P&gt;Do you know what the WHILE () option on a DO statement does?&lt;/P&gt;
&lt;P&gt;Do you know what INPUT does?&lt;/P&gt;
&lt;P&gt;Do you know what the _INFILE_ automatic variable is?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 14:37:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-send-a-unix-command-to-a-unix-server-using-a-pipe-command/m-p/916479#M44312</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-02-16T14:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to send a unix command to a unix server using a pipe command</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-send-a-unix-command-to-a-unix-server-using-a-pipe-command/m-p/916504#M44313</link>
      <description>&lt;PRE class="language-sas"&gt;&lt;CODE&gt;data _null_; 
  set filelisting;
  infile unix pipe filevar=unixcommand end=eof;
  do while (not eof);
    input;
    put _infile_;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;I might be wrong but what I think, is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;set filelisting; is use to select the dataset that I want to use&lt;/P&gt;
&lt;P&gt;do while (not eof);&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;end&lt;/P&gt;
&lt;P&gt;will execute what at in between until the end of the file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;input statement read the file filelisting one record at the time&lt;/P&gt;
&lt;P&gt;which is put into _infile_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;infile unix pipe ????&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 16:21:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-send-a-unix-command-to-a-unix-server-using-a-pipe-command/m-p/916504#M44313</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2024-02-16T16:21:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to send a unix command to a unix server using a pipe command</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-send-a-unix-command-to-a-unix-server-using-a-pipe-command/m-p/916508#M44314</link>
      <description>&lt;P&gt;Close.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The SET statement reads the next observation from the input dataset.&lt;/P&gt;
&lt;P&gt;The INFILE statement tells SAS where to read data from when you run an INPUT statement.&amp;nbsp; This one says to use the PIPE device type and use the variable referenced in the FILEVAR= option as the name of the file to read.&amp;nbsp; But since you are using the PIPE device it is not really the name of a file, but instead it is the command to by run whose piped output is what will be read.&amp;nbsp; The END= option says to use the variable named EOF as the one that will be set TRUE when you have read past the end of this file.&lt;/P&gt;
&lt;P&gt;The DO WHILE() will then iterate as long as there is more output coming from the command.&lt;/P&gt;
&lt;P&gt;The INPUT statement is used to read in from a text file.&amp;nbsp; When you read a line SAS will populate the _INFILE_ automatic variable with the content of that line.&amp;nbsp; So an INPUT statement with no other options just populates that _INFILE_ variable without modifying any other variables.&lt;/P&gt;
&lt;P&gt;The PUT statement writes text to the LOG (or what ever file you have opened with the most recent FILE statement).&amp;nbsp; In this case it is just going to write the _INFILE_ automatic variables.&amp;nbsp; So the DO loop writes all (any) output that the Unix command generated to the SAS log.&amp;nbsp; Note that a lot of commands will not write any output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data step will execute until it stops.&amp;nbsp; This particular one will stop when the SET statement reads past the end of its input SAS dataset.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 16:31:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-send-a-unix-command-to-a-unix-server-using-a-pipe-command/m-p/916508#M44314</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-02-16T16:31:06Z</dc:date>
    </item>
  </channel>
</rss>

