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

I need to write a script for Linux to do automated SAS Metadata Security Exports on a daily basis.

 

But the Control-M Scheduler must pick up the script located in our SAN folders and execute it on one of the Metadata Cluster Nodes.

How would I specify this Node in the Linux Code?

 

So far the Linux script has:

 

# =====SAS METADATA EXPORT OF MKTG SAS ACTs
 
#--- Declare Script Variables ---#
typeset currentdate="$(date +'%Y%m%d')"
typeset bin_loc="/opt/sasbin/software/SASPlatformObjectFramework/9.4"
typeset log_loc="/sasdata/SASAdmin/content_promotion/logs"
typeset runas_acc="SASAdmin.swa"
# =====

$bin_loc/ExportPackage -profile $runas_acc -package "$spk_loc/Marketing_ACTs_Export.spk" -disableX11
-objects "/System/Security/Access Control Templates/MKTG PROD Read Only ACT(ACT)" 
"/System/Security/Access Control Templates/SALES PROD ACT(ACT)" 
-subprop 
-includeDep
-modified
-log $log_loc/MKTG_ACTs_Export_Log_$currentdate.log;

Err_Exports ACT
Err_Log_File $log_loc/MKTG_ACTs_Export_Log_$currentdate.log
if [ $? -eq 8 ]
then
    exit 8
fi

Err_Log_File()
{
        find $1 |while read file
        do
                RESULT=$(egrep -i "error" $file)
                if [[ ! -z $RESULT ]]
                then
                        echo -e "$RESULT";
                        return 8;
                fi
        done
}

# == do the same for Groups

 

I need to test this first by running the  Linux script file. Normally one would SSH from the current server into the remote server. I am not a Linux script master. So not sure how to do this. I know hhow to do this in Powershell Win 2012 R2 but not too familiar with Linux BASH scripting...

1 ACCEPTED SOLUTION

Accepted Solutions
jklaverstijn
Rhodochrosite | Level 12

This is not really a SAS problem, but hey...

 

Generally, executing a remote command using SSH goes like:

 

ssh userid@remotehost "your command".

 

In your case it would involve having the entire script executed remotely. Your command would be ExportPackage and its parameters or perhaps the entire script.

 

You can add options to ssh to avoid chatter that cannot be handled when running non-interactively. Most noteworthy are '-PasswordAuthentication no', 'StrictHostKeyChecking no' and 'LogLevel quiet'. Also you must have your public key shared between the hosts so you can use ssh passwordless.

 

And keep in mind that the resulting package and log files will be created remotely as well. So unless you have a shared filesystem you will have to scp them back to the calling host as a next step.

 

Do keep in mind that this command does not need to be executed on the metadata server. It can be done from any machine that has SAS installed at or least the SASPlatformObjectFramework installed and an unhindered network connection to the metadata server.

 

Hope this helps,

-- Jan.

View solution in original post

2 REPLIES 2
jklaverstijn
Rhodochrosite | Level 12

This is not really a SAS problem, but hey...

 

Generally, executing a remote command using SSH goes like:

 

ssh userid@remotehost "your command".

 

In your case it would involve having the entire script executed remotely. Your command would be ExportPackage and its parameters or perhaps the entire script.

 

You can add options to ssh to avoid chatter that cannot be handled when running non-interactively. Most noteworthy are '-PasswordAuthentication no', 'StrictHostKeyChecking no' and 'LogLevel quiet'. Also you must have your public key shared between the hosts so you can use ssh passwordless.

 

And keep in mind that the resulting package and log files will be created remotely as well. So unless you have a shared filesystem you will have to scp them back to the calling host as a next step.

 

Do keep in mind that this command does not need to be executed on the metadata server. It can be done from any machine that has SAS installed at or least the SASPlatformObjectFramework installed and an unhindered network connection to the metadata server.

 

Hope this helps,

-- Jan.

Lenvdb
Quartz | Level 8

Thank you Jan

Running this on any server in the cluster that has SASPlatformObjectsFramework installed is the solution...No requirement then for running it remotely.

Len

suga badge.PNGThe SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment. 

Join SUGA 

Get Started with SAS Information Catalog in SAS Viya

SAS technical trainer Erin Winters shows you how to explore assets, create new data discovery agents, schedule data discovery agents, and much more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1120 views
  • 3 likes
  • 2 in conversation