Running Shell Commands in Enterprise Guide
I was having massive issues trying to run shell commands in Enterprise Guide a while back. I first tried asking for help on the SAS google group. My original post was as follows:
Somehow I need to change the startup options for Enterprise Guide to allow XCMD (shell access). How do I do this?
I’ve been having real difficulties with this. I’ve scoured the net, but there seems to be no working solution from support.sas.com, google groups or other web search results.
In SAS 9.1.3 I can run notepad.exe (or any other command like del, copy etc…) from the code editor by doing
x “notepad”;
%SYSEXEC notepad; in the code editor will also work.
When trying to run any X or %SYSEXEC from Enterprise Guide 4.1, it will not work. I read that doing the following in EG will work but it does not work for me:
SYSTASK COMMAND “notepad”;
It gives the error: “ERROR: Insufficient authorization to access SYSTASK COMMAND.”
When I run X command or %SYSEXEC from EG, I get the following error: “WARNING: Shell escape is not valid in this SAS session.”
So, SYSTASK COMMAND seems to work better than X or %SYSEXEC, but I don’t seem to have permissions in EG to do it.
I only SAS and EG on my local WinXP XP2 computer, so changing the startup configuration to allow shell access poses no security issues to me.
I’ve tried
proc options option=xcmd; run;
proc options option=xwait; run;
and then trying to run X or the others, but it does not change
anything.
Help!
A number of people tried to help, but nothing would work. So I tried the SAS Support Ticket and they gave me a nice fix. Here it is:
See the following information for being able to submit an X statement.
The first portion is for local servers only. The second part is for
remote servers:
By default, Enterprise Guide submits the option -noxcmd at SAS
startup.
This causes an error in Enterprise Guide if you attempt to submit an X
command from a Code window. If a SYSTASK command cannot be used
instead of an X command, then use the following method to modify the
registry key so that an X command can be submitted from the Code
window in Enterprise Guide.
These steps work for SAS Enterprise Guide 1.x, 2.x, 3.x, and 4.x.
1. Start => Run => enter REGEDIT => OK.
2. Select hkey_classes_root => clsid => 440196D4….. =>
localserver32.
3. Right-mouse on Default and select Modify.
4. Be careful here.
5. Remove -noxcmd (should be the last item in the list) => Ok.
6. View => Refresh.
7. Exit the Registry window.
8. Start EG and open a new project. Select Insert => Code => New.
9. Here is some simple code to test the X command:
/* Note: no need to submit a LIBNAME */
data a;
X “copy c:\testdata\test.sas7bdat c:\testdata\test2.sas7bdat”;
testvar=1;
run;
10. Right-mouse => select Local server.
11. A DOS window will appear with the message that the file was
copied.
12. Close the DOS window and the DATA step will complete.
Warning: Always back up your registry before you make any registry
changes. For assistance, see Windows Help, Microsoft documentation, or
the Microsoft Windows Web site. SAS Institute is not responsible when
you edit the Windows registry. Changes in the Windows registry can
render your system unusable and will require that you reinstall the
operating system.
Here are the steps to add the -nonoxcmd for an IOM server.
>From the SAS server machine:
1. Control Panel > Admin Tools > Services 2. RightMouse on SAS Object
Spawner > select Stop.
3. Start > Run > cmd > ok.
4. cd program files\sas institute\sas\v8\inttech\sasexe ENTER.
5. > objspawn -deinstall ENTER.
6. > objspawn -cf c:\objspawn.cfg -install -nonoxcmd ENTER.
7. Control Panel > Admin Tools > Services 8. From the menu bar >
Action > Refresh 9. RightMouse on SAS Object Spawner > select Start.
>From the EG client machine, Exit EG, restart EG, test the X command.
Have fun interacting with the Command line in EG!


Reader Comments (2)
Wow! Fantastic! I searched for a solution a long time! It works great!
Thanks so much!
Louis
Glad it helped. I also searched for a solution for weeks before calling SAS. They responded that day with a solution. All those weeks were wasted... :(