- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello everyone How can I create run time directory on SAS unix server and other OS specific commands ls, pwd...etc via SAS Enterprise guide using X command. I did X commands in SAS sessions from EG to run some OS specific commands such as mkdir,ls,pwd...but it looks like they are not working. below is the one of the x command I tried
x ls -l;
12NODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
13 STYLE=HtmlBlue
14 STYLESHEET=(URL="file:///C:/Program%20Files%20(x86)/SASHome94/x86/SASEnterpriseGuide/7.1/Styles/HtmlBlue.css")
15 NOGTITLE
16 NOGFOOTNOTE
17 GPATH=&sasworklocation
18 ENCODING=UTF8
19 options(rolap="on")
20 ; NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
21
22 GOPTIONS ACCESSIBLE;
23 x ls -l 23 ! ;
24
25 GOPTIONS NOACCESSIBLE;
26 %LET _CLIENTTASKLABEL=;
27 %LET _CLIENTPROJECTPATH=;
28 %LET _CLIENTPROJECTNAME=;
29 %LET _SASPROGRAMFILE=;
30
31 ;*';*";*/;quit;run;
32 ODS _ALL_ CLOSE;
33
This is our new SAS 9.4 Environment,so am not sure How this commands will work from SAS EG,do I need to enable something somewhere in the Tools or may be am using the commands wrongly. I would really appreciate if someone can help me on this Thank you in Advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
To be very specific how to create directory
I use following statement. Option dlcreatedir helps to create new directory if it is not present.
options dlcreatedir;
libname temp "C:\users\New_folder";
libname temp;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Do you have administration privileges for your SAS installation?
You do need to enable X command in EG as its turned off by default.
To create a folder you can use DCREATE
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
a) you need XCMD enabled on the workspace server; run proc options, and then look for XCMD in the log
b) to reliably catch the output of system commands, do this:
filename oscmd pipe "ls -l 2>&1";
data _null_;
infile oscmd;
input;
put _infile_;
run;
filename oscmd clear;
The 2>&1 reroutes stderr to stdout, so all output, including error messages, will be streamed to SAS. The data step then writes all output (if present) to the SAS log.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I need run a .sh file from UNIX. The .sh file contains a code to download an online file. Can you help me?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Please open a new thread with your question. Hijacking old threads is not useful, as you can see from the lack of any answers to your questions; old threads are near invisible to the crowd here.
Please include there:
the SAS code you run (use the "little running man" for this)
the shell script code (use the </> button)
the log from the SAS code, if available (also use the </> button)
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Addendum: When posting code, use the little "running man" icon to get a subwindow for entering code. Code will then be displayed in fixed-width font and with syntax highlighting similar to the SAS Enhanced Editor.
For log output or data, use the {i} icon. Fixed-width font, but no syntax highlighting.
This makes it much easier for others to read your posts.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Run my code and then post the complete log.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
There's nothing in your log to indicate it didn't work. You called the command but did nothing with results.
Whoch is much easier to see once I formatted your code.
Try A mkdir command to test it.
And review how to obtain results from ls.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Reeza thanks for your reply
This is how the command looks for mkdir right if am not wrong
X 'mkdir abc'
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@sasprofile wrote:
Reeza thanks for your reply
This is how the command looks for mkdir right if am not wrong
X 'mkdir abc'
Be aware that you specify a relative path (not starting at the UNIX root directory). This means that SAS will try to create the directory at the current working directory (CWD) of the SAS workspace server process.
With the SAS default installation, this is most probably the /sasconfig/Lev1/SASApp/WorkspaceServer directory, where you won't want to create a new directory, and where you most probably are not allowed to create anything.
Try
filename oscmd pipe "mkdir $HOME/abc 2>&1";
data _null_;
infile oscmd;
input;
put _infile_;
run;
filename oscmd clear;
instead and look at the log.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
KurtBremser
Thanks once again for your prompt replies, I really appreciate that
here is the log files for the two codes you sent,for the first code the directory created in the home directory
and the second code it listed some files...so it means the X command in EG is not working.
but why when am issuing the below commands its not working
x 'ls -l;
x 'pwd';
x 'cd /home/xu84178';
x 'ls -l > ls.txt ' ;
filename oscmd pipe "mkdir $HOME/abc 2>&1";
data _null_;
infile oscmd;
input;
put _infile_;
run;
filename oscmd clear;1 1 ;*';*";*/;quit;run;2 OPTIONS PAGENO=MIN;3 %LET _CLIENTTASKLABEL='Program';4 %LET _CLIENTPROJECTPATH='';5 %LET _CLIENTPROJECTNAME='';6 %LET _SASPROGRAMFILE=;7 8 ODS _ALL_ CLOSE;9 OPTIONS DEV=ACTIVEX;10 GOPTIONS XPIXELS=0 YPIXELS=0;11 FILENAME EGSR TEMP;12 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR13 STYLE=HtmlBlue14 STYLESHEET=(URL="file:///C:/Program%20Files%20(x86)/SASHome/x86/SASEnterpriseGuide/7.1/Styles/HtmlBlue.css")15 NOGTITLE16 NOGFOOTNOTE17 GPATH=&sasworklocation18 ENCODING=UTF819 options(rolap="on")20 ;NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR21 22 GOPTIONS ACCESSIBLE;23 filename oscmd pipe "mkdir /home/gx25664/abc 2>&1";24 data _null_;25 infile oscmd;26 input;27 put _infile_;28 run;NOTE: The infile OSCMD is: Pipe command="mkdir /home/gx25664/abc 2>&1"NOTE: 0 records were read from the infile OSCMD.NOTE: PROCEDURE| _DISARM| STOP| _DISARM| 2016-08-01T23:31:01,926-07:00| _DISARM| WorkspaceServer| _DISARM| SAS| _DISARM| | _DISARM| 19038208| _DISARM| 19038208| _DISARM| 11| _DISARM| 11| _DISARM| 0| _DISARM| 824| _DISARM| 0.010000| _DISARM| 0.022196| _DISARM| 1785738661.904777| _DISARM| 1785738661.926973| _DISARM| 0.010000| _DISARM| | _ENDDISARM NOTE: DATA statement used (Total process time): real time 0.02 seconds user cpu time 0.01 seconds system cpu time 0.00 seconds memory 765.28k OS Memory 18592.00k Timestamp 08/01/2016 11:31:01 PM Step Count 4 Switch Count 49 Page Faults 0 Page Reclaims 362 Page Swaps 0 Voluntary Context Switches 155 Involuntary Context Switches 0 Block Input Operations 0 Block Output Operations 0 29 filename oscmd clear;NOTE: Fileref OSCMD has been deassigned.30 31 GOPTIONS NOACCESSIBLE;32 %LET _CLIENTTASKLABEL=;33 %LET _CLIENTPROJECTPATH=;34 %LET _CLIENTPROJECTNAME=;35 %LET _SASPROGRAMFILE=;36 37 ;*';*";*/;quit;run;38 ODS _ALL_ CLOSE;39 40 41 QUIT; RUN;42
filename oscmd pipe "ls -l 2>&1";
data _null_;
infile oscmd;
input;
put _infile_;
run;
filename oscmd clear;1 ;*';*";*/;quit;run;2 OPTIONS PAGENO=MIN;3 %LET _CLIENTTASKLABEL='Program (2)';4 %LET _CLIENTPROJECTPATH='';5 %LET _CLIENTPROJECTNAME='';6 %LET _SASPROGRAMFILE=;7 8 ODS _ALL_ CLOSE;9 OPTIONS DEV=ACTIVEX;10 GOPTIONS XPIXELS=0 YPIXELS=0;11 FILENAME EGSR TEMP;12 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR13 STYLE=HtmlBlue14 STYLESHEET=(URL="file:///C:/Program%20Files%20(x86)/SASHome/x86/SASEnterpriseGuide/7.1/Styles/HtmlBlue.css")15 NOGTITLE16 NOGFOOTNOTE17 GPATH=&sasworklocation18 ENCODING=UTF819 options(rolap="on")20 ;NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR21 22 GOPTIONS ACCESSIBLE;23 filename oscmd pipe "ls -l 2>&1";24 data _null_;25 infile oscmd;26 input;27 put _infile_;28 run;NOTE: The infile OSCMD is: Pipe command="ls -l 2>&1"total 68-rw-r--r-- 1 sas sas 343 Jul 29 14:02 appserver_autoexec.sas-rw-r--r-- 1 sas sas 365 Jul 29 18:25 appserver_autoexec_usermods.sas-rw-r--r-- 1 sas sas 236 Jul 29 14:02 appserver_autoexec_usermods.sas_20160729_182516-rw-r--r-- 1 sas sas 437 Jul 29 14:02 appservercontext_env.sh-rwxr-xr-x 1 sas sas 203 Jul 29 14:02 appservercontext_env_usermods.shdrwxr-xr-x 4 sas sas 4096 Jul 29 18:25 BatchServerdrwxr-xr-x 3 sas sas 4096 Jul 29 18:25 ConnectServerdrwxr-xr-x 2 sas sas 4096 Jul 29 14:02 Datadrwxr-x--- 5 sas sas 4096 Jul 29 18:25 PooledWorkspaceServerdrwxr-xr-x 5 sas sas 4096 Jul 29 14:02 SASEnvironment-rwxr-xr-x 1 sas sas 894 Jul 29 14:02 sas.sh-rwxr-xr-x 1 sas sas 165 Jul 29 14:02 sas_usermods.sh-rw-r--r-- 1 sas sas 1141 Jul 29 14:02 sasv9.cfg-rw-r--r-- 1 sas sas 295 Jul 29 14:02 sasv9_usermods.cfgdrwxr-x--- 5 sas sas 4096 Jul 29 18:25 StoredProcessServerdrwxrwxr-x 2 sas sas 4096 Aug 1 18:15 testdrwxr-xr-x 4 sas sas 4096 Jul 29 18:25 WorkspaceServerNOTE: 18 records were read from the infile OSCMD. The minimum record length was 8. The maximum record length was 86.NOTE: PROCEDURE| _DISARM| STOP| _DISARM| 2016-08-01T23:39:15,542-07:00| _DISARM| WorkspaceServer| _DISARM| SAS| _DISARM| | _DISARM| 20877312| _DISARM| 19300352| _DISARM| 11| _DISARM| 11| _DISARM| 8| _DISARM| 872| _DISARM| 0.020000| _DISARM| 0.025575| _DISARM| 1785739155.516796| _DISARM| 1785739155.542371| _DISARM| 0.010000| _DISARM| | _ENDDISARM NOTE: DATA statement used (Total process time):2 The SAS System real time 0.02 seconds user cpu time 0.01 seconds system cpu time 0.01 seconds memory 764.15k OS Memory 18848.00k Timestamp 08/01/2016 11:39:15 PM Step Count 6 Switch Count 92 Page Faults 0 Page Reclaims 308 Page Swaps 0 Voluntary Context Switches 335 Involuntary Context Switches 0 Block Input Operations 0 Block Output Operations 0 29 filename oscmd clear;NOTE: Fileref OSCMD has been deassigned.30 31 GOPTIONS NOACCESSIBLE;32 %LET _CLIENTTASKLABEL=;33 %LET _CLIENTPROJECTPATH=;34 %LET _CLIENTPROJECTNAME=;35 %LET _SASPROGRAMFILE=;36 37 ;*';*";*/;quit;run;38 ODS _ALL_ CLOSE;39 40 41 QUIT; RUN;42
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
KurtBremser
Sorry typo error *so it means the X command in EG is working
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The X command/statement does not retrieve any output back into the SAS system.
So you won't get any information for
x 'ls -l;
x 'pwd';
The next two commands
x 'cd /home/xu84178';
x 'ls -l > ls.txt ' ;
should create a list of files in (what I guess is) your home directory. Do a refresh on Files in the server list in EG to see if the file (ls.txt) is there.
Note that a cd command in the X statement will change the CWD of the SAS process. Executing it with the filename pipe method won't do that.
This indicates that SAS executes commands from X directly, while filename pipe uses a shell exit (therefore changes to the environment are lost when that sub-shell terminates)