BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
woo
Barite | Level 11 woo
Barite | Level 11

Hello, 

 

i am trying to get my linux command line output via email (email out sas service status). what is best way to do that (except sas evm)

 

i can get sas services using this code, but it still output status on cmd line only. i am trying to find a way where i can have this status output directly to my email...Thank you - 

 

data _null_;

x cd /....../config/Lev1;

x "./sas.servers status";

run;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ScottBass
Rhodochrosite | Level 12
proc report data=sashelp.class nowd noheader;
run;

Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.

View solution in original post

9 REPLIES 9
ChrisNZ
Tourmaline | Level 20

I am unsure what you are trying to achieve.

Have you tried the pipe option for the FILENAME statement?

 

Hello, 

 

i am trying to get my linux command line output via email (email out sas service status). what is best way to do that (except sas evm)

 

i can get sas services using this code, but it still output status on cmd line only. i am trying to find a way where i can have this status output directly to my email...Thank you - 

 

data _null_;

x cd /....../config/Lev1;

x "./sas.servers status";

run;

woo
Barite | Level 11 woo
Barite | Level 11

goal is to get sas service status in email. email should shows output of (./sas.servers status)...

 

 

ScottBass
Rhodochrosite | Level 12

@woo wrote:

goal is to get sas service status in email. email should shows output of (./sas.servers status)...

 

 


Ok, you don't need SAS for that then.

 

Try "man sendmail" or "man mail".  Then a simple bash command would do it.

 

Perhaps try this (untested):

 

#!/usr/bin/bash

cd /path/to/config/Lev1
./sas.servers status | sendmail your@emailaddress

 

https://tecadmin.net/ways-to-send-email-from-linux-command-line/

 

Edit: 

P.S.:  If you don't get joy here, try posting in the SAS Admin group.  What you've described is SAS Administration, not SAS Programming.


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
ScottBass
Rhodochrosite | Level 12

What you have displayed is not "linux command line output", it is "SAS X command output".  Sort off...data _null_ doesn't really have output per se.

 

Questions:

 

1) Please define *exactly* what you mean by linux command line.

 

2) Are you wanting to send this email via linux (sendmail, etc) or via SAS's email support (filename email...)?

 

3) If the latter, perhaps this would help?  https://github.com/scottbass/SAS/blob/master/Macro/sendmail.sas

 

4) Can you provide a better example of the email you want to send?  The example contents may give us a clue whether you mean sending an email from linux itself or from SAS.


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
woo
Barite | Level 11 woo
Barite | Level 11

Thank you Scoot. 

 

that Linux cmd would work as well. I was more looking at the sas code as i want to add some more details along with status like, 

 

<header>

SAS Status <hostname>

Prod environment 

 

<output of ./sas.servers status>

 

i am going to try ods way, will see if i can get it done...Thank you - 

ScottBass
Rhodochrosite | Level 12

Then investigate FILENAME PIPE as suggested by @ChrisNZ to get the script output into a SAS dataset, then email from there.

 

(Of course, you could add your HTML formatting in your bash script as well...)


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
woo
Barite | Level 11 woo
Barite | Level 11

Thanks appreciate your direction...and input... 

 

this seems working so far,

 

data step with infile statetment like, 

infile "cd /...Lev1; ./sas.servers status;" pipe;

 

then filename statement for email with ods html with some title statement and proc print data.

 

however, when i receive email, its showing "obs" and "record" as variable - i tried different way to remove header but no luck so far, 

 

obs  record 

1       SAS server status

2       SAS Web Infrastructure Data Server is up

3       SAS Object Spawner 1 is up

4

5

 

 

 

ScottBass
Rhodochrosite | Level 12
proc report data=sashelp.class nowd noheader;
run;

Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
woo
Barite | Level 11 woo
Barite | Level 11

Thanks Scoot. I was using proc print with those options...which gave me no output in email...but proc report worked perfectly...

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 2278 views
  • 2 likes
  • 3 in conversation