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

Hi

Can anybody help me with the commands needed to launch a DI Job (containing other DI jobs and an input file)?

It is on Linux and it has to be a shell script.

Thanks in advance

Kind regards

Andreas

1 ACCEPTED SOLUTION

Accepted Solutions
LinusH
Tourmaline | Level 20

The shell script will return any SAS session RC. Whether it's easy or not capture this depends on how you will call/execute the scripts.

Now you are outside SAS. So this information is best gathered from your Linux or batch admin.

Data never sleeps

View solution in original post

13 REPLIES 13
LinusH
Tourmaline | Level 20

Deploy your DI job. The command line is part of the deployed jobs meta data.

Data never sleeps
DaveR_SAS
SAS Employee

This user guide topic might be relevant: SAS(R) Data Integration Studio 4.9: User's Guide

The command-line  deployment tool enables you run an Ant script to deploy one or more jobs through a simple command-line interface.Use other software to schedule the job for execution.

LinusH
Tourmaline | Level 20

Interesting, I've managed to miss the feature.

But I think the OP asked for how to launch a deployed job, not launch the deployment itself. So I think your answer suits this thread better :

But when we are at the topic, the described process seems a bit tedious. And I wonder what kind of requirement led you to develop this? I have never been in a project were it made sense to auto-deploy jobs, especially in batch.

If you are looking to make promotion process easier, here are some wished for features (ideas free of charge... Smiley Happy 😞

  • During import, make it possible to "automatically" deploy selected jobs
  • Have the promotion process integrated, so you don't have select items, export to file, change profile, open package, analyze, import, then seek and deploy jobs. Would be nice ta have all this in one wizard.
Data never sleeps
DaveR_SAS
SAS Employee

Thanks for your reply, Linus! I knew that your answer was simpler and  more direct than mine. But if you wanted to automate both the deployment and the execution of the job, I thought that you might be able to use the method in the topic above to deploy the job in batch and then use a scheduler to actually execute the job in batch. In any case, I'll pass your suggestions along to development. Thanks again for your patience and for taking the time to reply.

LinusH
Tourmaline | Level 20

Thanx, the pleasure is on my side Smiley Happy

Data never sleeps
andreas_gryn
Calcite | Level 5

Hi

Thank for all the input but I think you are talking about deploying and not executing.

When I deploy my SAS DI job I get my .sas file

I now want to execute it using a shell script.

Do you have an example/doc for this issue?

Thanks in advance

Kurt_Bremser
Super User

To run a SAS program stored as a .sas file in batch, you need the following commandline:

/path_to_sas/sas -config your_sasv9.cfg -autoexec your_sasv9_autoexec.sas -log your_logfile.log programname.sas

autoexec and config can/must be used to set an environment that corresponds to the environment your DI studio uses.

andreas_gryn
Calcite | Level 5

Thanks.

I will implement this.

Is there also an easy way to capture the returncode of the job to use in errorhandling of the shell?

LinusH
Tourmaline | Level 20

The shell script will return any SAS session RC. Whether it's easy or not capture this depends on how you will call/execute the scripts.

Now you are outside SAS. So this information is best gathered from your Linux or batch admin.

Data never sleeps
Kurt_Bremser
Super User

Immediately after the execution of a command, the shell assigns the return code to the environment variable "?".

So, the next line after the one that calls SAS should look like

RC=$?

Now you have stored the return code of the SAS job in RC (use $RC to retrieve the value) and can use it.

IE if I find RC=0, I check the log file for certain phrases that indicate errors that SAS will not flag on its own (some peculiar FTP protocol answers from IBM mainframes come to mind), and set special error conditions if I encounter one. RC

The last line of the shell script is then

exit $RC

andreas_gryn
Calcite | Level 5

Thanks for the helpfull info.

1 question I still have 🙂

I have inserted this code and it works.

/sas/config/Lev1/SASApp/sas.sh -log /sas/common/Logs/test.log -sysin /sas/config/Lev1/SASApp/SASEnvironment/SASCode/Jobs/Jobflow_cons.sas

#----------------------------

# RETURN CODE

#----------------------------

STATUT=$?

Now I want to pass 2 parameters to the DI job.

How do I do that?

parameters are : ${MTH_REF}  and ${LOG_FILE}

Thanks again for the help

Kurt_Bremser
Super User

before the line where you call sas.sh, insert

export MTH_REF=xxxxxx

export LOG_FILE=yyyyyyy

Then you will be able to retrieve the values in SAS with the %sysget function.

Note the "export" command, which tells the UNIX shell to put the new environment variables in the global table, which is inherited by child processes.

LinusH
Tourmaline | Level 20

You can build a shell script the meta data way in SMC Schedule Manager plug in. See online doc or help within the product.

Data never sleeps

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 13 replies
  • 4497 views
  • 7 likes
  • 4 in conversation