<?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: Sending a Unix command and masking the percent % sign in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Sending-a-Unix-command-and-masking-the-percent-sign/m-p/483026#M125205</link>
    <description>&lt;P&gt;I would unload the whole UNIX code into a shell script that accepts all variable parts from the commandline ($1, $2 and so on). That way SAS never sees the format parameters etc, which are fixed in the script.&lt;/P&gt;
&lt;P&gt;Create a control table with all the information (server, diractory, file names), build the commandline in a data _null_ step, and use call execute to call the systask statement.&lt;/P&gt;</description>
    <pubDate>Wed, 01 Aug 2018 10:31:33 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-08-01T10:31:33Z</dc:date>
    <item>
      <title>Sending a Unix command and masking the percent % sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sending-a-Unix-command-and-masking-the-percent-sign/m-p/483024#M125204</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A brief description of my intent: I'm scanning file systems across several Unix servers. The Unix command is created dynamically in a Macro and used to be submitted via 'call systask'. I want to submit the statements in parallel, so now I'm going to use 'systask command nowait'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As I'm no long using the data _null_ with call systask I'm now building the Unix command in a fairly straightforward (but admittedly messy) %let statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The command works, however, the Unix command contains the percent % symbol and so the macro processor is trying to resolve things that don't exist. I know I can use %nrstr() to resolve this (that's what I did&amp;nbsp;with call systask) but this is not masking anything within the %let / systask command statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's a simple loop macro, but here's the line that builds the Unix command:&lt;/P&gt;&lt;PRE&gt;%let cmd = ssh -o StrictHostKeyChecking=no %sysfunc(quote(%sysfunc(scan(&amp;amp;server.,&amp;amp;i.,|)))) "find &amp;amp;dir. -type f -exec stat -c %nrstr('%n|%y|%x|%s|%U|%u|%G') {} \%nrstr(;)" &amp;gt; &amp;amp;projDir./Data/&amp;amp;fname.Logs_%sysfunc(scan(&amp;amp;server.,&amp;amp;i.,|)).txt;
systask command %sysfunc(quote(&amp;amp;cmd.)) nowait;&lt;/PRE&gt;&lt;P&gt;When it's compiled It looks like this:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ssh -o StrictHostKeyChecking=no "&lt;I&gt;servername&lt;/I&gt;" "find /&lt;EM&gt;dir1&lt;/EM&gt;/&lt;EM&gt;dir2&lt;/EM&gt;/&lt;EM&gt;dir3&lt;/EM&gt;/ -type f -exec stat -c '%n|%y|%x|%s|%U|%u|%G' {} \;"" &amp;gt; /&lt;EM&gt;dir1a&lt;/EM&gt;/&lt;EM&gt;dir2a&lt;/EM&gt;/&lt;EM&gt;dir3a&lt;/EM&gt;/&lt;EM&gt;filename&lt;/EM&gt;_&lt;EM&gt;servername&lt;/EM&gt;.txt&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code may send shivers down the spine of more seasoned coders - I have got myself in a rut because I've had to try all sorts of different methods to get this to work, so the code is admittedly not as efficient or tidy as I'd like.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help regarding the forcible masking of the percent symbols is appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dan&lt;/P&gt;</description>
      <pubDate>Wed, 01 Aug 2018 10:15:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sending-a-Unix-command-and-masking-the-percent-sign/m-p/483024#M125204</guid>
      <dc:creator>_Dan_</dc:creator>
      <dc:date>2018-08-01T10:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: Sending a Unix command and masking the percent % sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sending-a-Unix-command-and-masking-the-percent-sign/m-p/483026#M125205</link>
      <description>&lt;P&gt;I would unload the whole UNIX code into a shell script that accepts all variable parts from the commandline ($1, $2 and so on). That way SAS never sees the format parameters etc, which are fixed in the script.&lt;/P&gt;
&lt;P&gt;Create a control table with all the information (server, diractory, file names), build the commandline in a data _null_ step, and use call execute to call the systask statement.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Aug 2018 10:31:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sending-a-Unix-command-and-masking-the-percent-sign/m-p/483026#M125205</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-01T10:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: Sending a Unix command and masking the percent % sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sending-a-Unix-command-and-masking-the-percent-sign/m-p/483027#M125206</link>
      <description>Thanks for your reply &amp;amp; that's certainly a good option. I will need to consider it as a "last resort" of sorts until I've exhausted any options on coding it directly into the SAS Macro.</description>
      <pubDate>Wed, 01 Aug 2018 10:33:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sending-a-Unix-command-and-masking-the-percent-sign/m-p/483027#M125206</guid>
      <dc:creator>_Dan_</dc:creator>
      <dc:date>2018-08-01T10:33:09Z</dc:date>
    </item>
    <item>
      <title>Re: Sending a Unix command and masking the percent % sign</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sending-a-Unix-command-and-masking-the-percent-sign/m-p/483038#M125208</link>
      <description>&lt;P&gt;I've found the resolution: superq.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the end result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%let cmd = ssh -o StrictHostKeyChecking=no %sysfunc(quote(%sysfunc(scan(&amp;amp;server.,&amp;amp;i.,|)))) "find &amp;amp;dir. -type f -exec stat -c %nrstr('%n|%y|%x|%s|%U|%u|%G') {} \%nrstr(;)" &amp;gt; &amp;amp;projDir./Data/&amp;amp;fname.Logs_%sysfunc(scan(&amp;amp;server.,&amp;amp;i.,|)).txt;&lt;BR /&gt;systask command &lt;STRONG&gt;"%superq(cmd)"&lt;/STRONG&gt; nowait;&amp;nbsp;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Aug 2018 11:04:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sending-a-Unix-command-and-masking-the-percent-sign/m-p/483038#M125208</guid>
      <dc:creator>_Dan_</dc:creator>
      <dc:date>2018-08-01T11:04:46Z</dc:date>
    </item>
  </channel>
</rss>

