DATA Step, Macro, Functions and more

Shell command from SAS-EG

Reply
Contributor FK1
Contributor
Posts: 40

Shell command from SAS-EG

[ Edited ]

Hi There,

 

I do have a perfectly fine working shell command:

 

 

ssh johndoe@some.server.com > /home/some/path/test42.txt  mysql -u johnny -psomeawkwardpassword > /home/some/path/test42.txt <<< "select * from information_schema.TABLES WHERE table_schema = 'some_value' "

 

When running in a shell, I get the executed query results written to the text file "test42.txt"

 

However, when I try to execute this shell command from within SAS-EG I get a &sysrc=2 !

(Unfortunately, the SAS log does not include error messages from the operating system (or any output done to stdout and stderr) during execution of the shell command)

 

In the SAS-Log, however, I do not get any kind of error or warning whatsoever!

 

I am using %sysexec:

 

%sysexec  
%unquote(%nrbquote(
ssh johndoe@some.server.com
mysql -u johnny -psomeawkwardpassword > /home/some/path/test42.txt
<<< "select * from information_schema.TABLES WHERE table_schema = 'some_value' "))
;

 

 

What is the correct SAS-EG syntax?

Occasional Contributor
Posts: 19

Re: Shell command from SAS-EG

I don't think this is a syntax error.

Check the value of the SAS option XCMD. If it is set to NOXCMD then you are prevented from issuing shell commands. You may be able to reset it to XCMD but your sys admin may have prevented this.

Contributor FK1
Contributor
Posts: 40

Re: Shell command from SAS-EG

I checked it. It is turned on, i.e. I can send x commands from within SAS-EG:

 

cxmd-option.JPG

Super User
Posts: 6,637

Re: Shell command from SAS-EG

A small step to try ... this particular command does not require %nrbquote.  Try getting rid of %unquote and %nrbquote and the two sets of parentheses and see if that improves the information you receive about where the problem lies.

Ask a Question
Discussion stats
  • 3 replies
  • 145 views
  • 0 likes
  • 3 in conversation