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;
proc report data=sashelp.class nowd noheader;
run;
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;
goal is to get sas service status in email. email should shows output of (./sas.servers status)...
@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.
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.
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 -
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...)
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
proc report data=sashelp.class nowd noheader;
run;
Thanks Scoot. I was using proc print with those options...which gave me no output in email...but proc report worked perfectly...
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!
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.
Ready to level-up your skills? Choose your own adventure.