Hi all,
I'm excuting the following code out of a SAS EG session (Win7, SAS 9.4, EG 7.13 HF3).
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 &metapw_tmp");
cmd=catx(' ',cmd,"-time 2017-03-16T18:22:27");
cmd=catx(' ',cmd,"-rollForward");
cmd=catx(' ',cmd,"-list");
/* cmd=catx(' ',cmd,'>>c:\temp\list.txt');*/
call system(cmd);
stop;
run;
This works as expected and I'm seeing the following in a DOS prompt:
I've got two challenges where I just can't find a solution.
1. Capture message
I would like to capture the returned message from sas-recover_metadata.exe - just what I get in the DOS prompt in above screen shot.
When running the command directly out of a DOS prompt I simply add >>c:\temp\list.txt. That works just fine. BUT when I'm adding this bit to my call system() command as done in above code (the bit in comment) then things fall over and I end up with the following:
What am I missing??
2. Suppress DOS window
When using call system() is there any way how I could suppress the DOS prompt to show up? Something similar to -nosplash?
What I actually want: Just run sas-recover_metadata.exe 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).
Any guidance, pointers or working code would be highly appreciated.
What's a given: Execution out of SAS EG and/or a Stored Process.
Hello @Patrick,
nice question! 🙂
Let me please answer your direct questions, then I will add some considerations:
My main consideration here would be:
cmd="your_bat_file &your_datetime";
call system(cmd);
Way simplier for you and, linked to my previous comment, more secure.
Hello @Patrick,
nice question! 🙂
Let me please answer your direct questions, then I will add some considerations:
My main consideration here would be:
cmd="your_bat_file &your_datetime";
call system(cmd);
Way simplier for you and, linked to my previous comment, more secure.
Hi @JuanS_OCS
Firstly thanks a lot for your fast and detailed answer. That was very helpful :-);
The Pipe did the trick for me - quoting was a b... though.
%metaEnvInit(metapw=y);
options noxwait xsync;
data _null_;
length cmd $2000;
cmd="""""&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 &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 "&cmd";
data _null_;
file print;
infile test;
input;
put _infile_;
run;
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.
My first choice would be SMC but if EG or a Web Interface is a must then 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 -profile 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.
Thanks again for your support. That really helped.
The SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment.
Learn how to install the SAS Viya CLI and a few commands you may find useful in this video by SAS’ Darrell Barton.
Find more tutorials on the SAS Users YouTube channel.