<?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: sas-recover-metadata executed via call system() out of SAS EG in Administration and Deployment</title>
    <link>https://communities.sas.com/t5/Administration-and-Deployment/sas-recover-metadata-executed-via-call-system-out-of-SAS-EG/m-p/341521#M7935</link>
    <description>&lt;P&gt;Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;nice question! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me please answer your direct questions, then I will add some considerations:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Capture the message:
&lt;OL&gt;
&lt;LI&gt;first I would try by adding some spaces between the "&amp;gt;&amp;gt;" sign&amp;gt; Somehow it looks as the command is recognizing the output pipe as a parameter.&lt;/LI&gt;
&lt;LI&gt;Secondly, in order to capture the output of system commands, SAS generally recoments to use the FILENAME - PIPE combo: &lt;A href="http://blogs.sas.com/content/sgf/2016/03/11/using-a-pipe-to-return-the-output-of-an-operating-system-command-to-sas-software/" target="_blank"&gt;http://blogs.sas.com/content/sgf/2016/03/11/using-a-pipe-to-return-the-output-of-an-operating-system-command-to-sas-software/&lt;/A&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;LI&gt;Supress DOS window:
&lt;OL&gt;
&lt;LI&gt;the system command "START /MIN /B your_program &amp;gt;&amp;gt; your_output.log" is your friend, and the closest to the Linux command "your_program &amp;amp;". You can use Powershell (&lt;SPAN style="text-align: left; color: rgb(36, 39, 41); text-transform: none; text-indent: 0px; letter-spacing: normal; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; orphans: 2; widows: 2; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;start -NoNewWindow your_program &lt;/SPAN&gt;), as well as other tricks that can be googled.&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My main consideration here would be:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Try to prevent as much as possible&amp;nbsp;to pass paswords as normal macro variables, specially if it is the sasadm@saspw user's and through a EG session. Sorry, I had to say it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/LI&gt;
&lt;LI&gt;I would just create a bat file on the server itself, with all your command, with the parameter of the datetime only, for the "-time" option. Then you can make a simple call to
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;cmd="your_bat_file &amp;amp;your_datetime";
call system(cmd);&lt;/CODE&gt;&lt;/PRE&gt;
Way simplier for you and, linked to my previous comment, more secure.&lt;/LI&gt;
&lt;LI&gt;STP would be better than EG (since you can make available this to relevant locations and with a prompt), but, still, a batch process with no log to EG, except the exit of the command, would be even better&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Mar 2017 10:47:24 GMT</pubDate>
    <dc:creator>JuanS_OCS</dc:creator>
    <dc:date>2017-03-16T10:47:24Z</dc:date>
    <item>
      <title>sas-recover-metadata executed via call system() out of SAS EG</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/sas-recover-metadata-executed-via-call-system-out-of-SAS-EG/m-p/341518#M7934</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/bisag/68240/HTML/default/viewer.htm#p0m27cjip6kjkvn1lhz7q8gjozyo.htm&amp;nbsp;" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/bisag/68240/HTML/default/viewer.htm#p0m27cjip6kjkvn1lhz7q8gjozyo.htm&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm excuting&amp;nbsp;the following code out of a SAS EG session (Win7,&amp;nbsp;SAS 9.4, EG&amp;nbsp;7.13 HF3).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options noxwait xsync;
data _null_;
  length cmd $2000;
  cmd='"C:\Program Files\SASHome\SASPlatformObjectFramework\9.4\tools\admin\sas-recover-metadata.exe"';
  cmd=catx(' ',cmd,"-host %sysfunc(getoption(metaserver))");
  cmd=catx(' ',cmd,"-port %sysfunc(getoption(metaport))");
  cmd=catx(' ',cmd,"-user %sysfunc(getoption(metauser))"); 
  cmd=catx(' ',cmd,"-password &amp;amp;metapw_tmp"); 
  cmd=catx(' ',cmd,"-time 2017-03-16T18:22:27"); 
  cmd=catx(' ',cmd,"-rollForward"); 
  cmd=catx(' ',cmd,"-list");
/*  cmd=catx(' ',cmd,'&amp;gt;&amp;gt;c:\temp\list.txt');*/
  call system(cmd);
  stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This works as expected and I'm seeing the following in a DOS prompt:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7779iD4773CFA403B1339/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've got two challenges where I just can't find a solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;1. Capture message&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;I would like to capture the returned message from &lt;EM&gt;sas-recover_metadata.exe&lt;/EM&gt; - just what I get in the DOS prompt in above screen shot.&lt;/P&gt;
&lt;P&gt;When running the command directly out of a DOS prompt I simply add&amp;nbsp;&lt;EM&gt;&amp;gt;&amp;gt;c:\temp\list.txt.&lt;/EM&gt; That works just fine. BUT when I'm adding this bit to my &lt;EM&gt;call system()&lt;/EM&gt; command as done in above code (the bit in comment) then things fall over and I end up with the following:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/7780i3AB414CAFD346D72/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;
&lt;P&gt;What am I missing??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;2. Suppress DOS window&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;When using &lt;EM&gt;call system()&lt;/EM&gt; is there any way how I could suppress the DOS prompt to show up? Something similar to -nosplash?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I actually want: Just run &lt;EM&gt;sas-recover_metadata.exe&lt;/EM&gt; and write any return messages back to the SAS log. I understand that this runs as a child process so I was thinking to just write everything to a temporary file and then write the content of this file back to the SAS log (via a data _null_ step).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any guidance, pointers or working code&amp;nbsp;would be highly appreciated.&lt;/P&gt;
&lt;P&gt;What's a given: Execution&amp;nbsp;out of SAS EG and/or a Stored Process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 10:24:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/sas-recover-metadata-executed-via-call-system-out-of-SAS-EG/m-p/341518#M7934</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-03-16T10:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: sas-recover-metadata executed via call system() out of SAS EG</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/sas-recover-metadata-executed-via-call-system-out-of-SAS-EG/m-p/341521#M7935</link>
      <description>&lt;P&gt;Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;nice question! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me please answer your direct questions, then I will add some considerations:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Capture the message:
&lt;OL&gt;
&lt;LI&gt;first I would try by adding some spaces between the "&amp;gt;&amp;gt;" sign&amp;gt; Somehow it looks as the command is recognizing the output pipe as a parameter.&lt;/LI&gt;
&lt;LI&gt;Secondly, in order to capture the output of system commands, SAS generally recoments to use the FILENAME - PIPE combo: &lt;A href="http://blogs.sas.com/content/sgf/2016/03/11/using-a-pipe-to-return-the-output-of-an-operating-system-command-to-sas-software/" target="_blank"&gt;http://blogs.sas.com/content/sgf/2016/03/11/using-a-pipe-to-return-the-output-of-an-operating-system-command-to-sas-software/&lt;/A&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;LI&gt;Supress DOS window:
&lt;OL&gt;
&lt;LI&gt;the system command "START /MIN /B your_program &amp;gt;&amp;gt; your_output.log" is your friend, and the closest to the Linux command "your_program &amp;amp;". You can use Powershell (&lt;SPAN style="text-align: left; color: rgb(36, 39, 41); text-transform: none; text-indent: 0px; letter-spacing: normal; font-family: Arial, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-weight: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; orphans: 2; widows: 2; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"&gt;start -NoNewWindow your_program &lt;/SPAN&gt;), as well as other tricks that can be googled.&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My main consideration here would be:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Try to prevent as much as possible&amp;nbsp;to pass paswords as normal macro variables, specially if it is the sasadm@saspw user's and through a EG session. Sorry, I had to say it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/LI&gt;
&lt;LI&gt;I would just create a bat file on the server itself, with all your command, with the parameter of the datetime only, for the "-time" option. Then you can make a simple call to
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;cmd="your_bat_file &amp;amp;your_datetime";
call system(cmd);&lt;/CODE&gt;&lt;/PRE&gt;
Way simplier for you and, linked to my previous comment, more secure.&lt;/LI&gt;
&lt;LI&gt;STP would be better than EG (since you can make available this to relevant locations and with a prompt), but, still, a batch process with no log to EG, except the exit of the command, would be even better&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 10:47:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/sas-recover-metadata-executed-via-call-system-out-of-SAS-EG/m-p/341521#M7935</guid>
      <dc:creator>JuanS_OCS</dc:creator>
      <dc:date>2017-03-16T10:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: sas-recover-metadata executed via call system() out of SAS EG</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/sas-recover-metadata-executed-via-call-system-out-of-SAS-EG/m-p/341561#M7937</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35204"&gt;@JuanS_OCS&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Firstly thanks a lot for your fast and detailed answer. That was very helpful :-);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The&lt;EM&gt; Pipe&lt;/EM&gt; did the trick for me - quoting was a b... though.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%metaEnvInit(metapw=y);

options noxwait xsync;
data _null_;
  length cmd $2000;
  cmd="""""&amp;amp;adminTools\sas-recover-metadata.exe""""";
  cmd=catx(' ',cmd,"-host %sysfunc(getoption(metaserver))");
  cmd=catx(' ',cmd,"-port %sysfunc(getoption(metaport))");
  cmd=catx(' ',cmd,"-user %sysfunc(getoption(metauser))"); 
  cmd=catx(' ',cmd,"-password &amp;amp;metapw_tmp"); 
  cmd=catx(' ',cmd,"-time %sysfunc(datetime(),e8601dt19.)"); 
  cmd=catx(' ',cmd,"-rollForward"); 
/*  cmd=catx(' ',cmd,"-list");*/
/*  put cmd;*/
  call symputx('cmd',cmd);
  stop;
run;
%symdel metapw_tmp;

filename test pipe "&amp;amp;cmd";
data _null_;
  file print;
  infile test;
  input;
  put _infile_;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I agree with everything you write. What I'm doing is in the moment only for a demo so it doesn't need to be production worthy.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My first choice would be SMC but if EG or a Web Interface is a must then&amp;nbsp;I believe I'd go for a stored process which uses a secure compiled macro where I'd have full control what gets written to the log - or even better I can use the &lt;EM&gt;-profile&lt;/EM&gt; option and don't need to pass in credentials at all. But that's still in the future and I don't even have the requirements yet to make such design decisions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again for your support. That really helped.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 13:12:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/sas-recover-metadata-executed-via-call-system-out-of-SAS-EG/m-p/341561#M7937</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-03-16T13:12:14Z</dc:date>
    </item>
  </channel>
</rss>

