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

Hello,

 

I'm automating the package deployment of all SAS objects like jobs, flow, etc.. from one Environment to the other using the Import/Export batch tool in an Unix script.

 

While performing the export, I do have some error and warnings.  I dont want to proceed further if there is a warning or error.

 

So I used the Returncode  in my script. But if there are any error/warning in export package , it still have the return code as Zero (Success ) .

 

I want to perform some action if there are warnings or errors. Please let me know how to action this.

 

THanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
gwootton
SAS Super FREQ

It sounds like the concern here is that the return code for the ExportPackage application may still be zero even if a warning or error is encountered.

Perhaps instead of using your logic testing against $?, you test against the contents of the log file. For example:

ExportPackage -profile "SASAdmin" -package /tmp/package.spk -objects "/User Folders/sasdemo" -includeDep -disableX11 -log /tmp/checkerr.log

err=$(grep -cE '(WARN|ERROR|FATAL)' /tmp/checkerr.log)

if [ "$err" =  '0' ]

then

echo "Export completed successfully."

else

echo "Export failed. See /tmp/checkerr.log for more details."

fi

--
Greg Wootton | Principal Systems Technical Support Engineer

View solution in original post

5 REPLIES 5
jklaverstijn
Rhodochrosite | Level 12

Working on the same right now! So I tested the following: run the ImportPackage command trying to import some objects to a floder for which  I have no metadata permissions at all. This obviously fails. And also I get a return code 4 (warnings, it's apparently not considered an error). Please elaborate on your actions as mine do not confirm your findings.

 

Edit: I am on Linux, RHEL8. and SAS 9.4M8.

 

Regards,

- Jan.

Nivas88
Calcite | Level 5

Thanks @jklaverstijn for your response.

 

I'm in SAS M7 and Red Hat Linux 7.

 

In  a script i uses  the export command for exporting Stored Process. After execution,  at the end export logs, it says "Completed successfully with errors'. When I scan the logs, below is the error message

 

Reason : Connection failed because of invalid credentials

 

above error is expected. So i had the return code syntax ( after my export command )   in my script as below

 

RETURN=$?

 

if [ $RETURN=0 ];

then

echo "Export package completed successfully"

else

echo "Export failed for some reason"

fi

 

The above syntax says "Export package completed successfully" even though my export command had errors.

How to resolve this ? I need "Export failed for some reason " as an output for these kind of scenarios.

 

Thank you

 

 

 

jklaverstijn
Rhodochrosite | Level 12

That error is certainly not because you failed to connect to the metadata server (the message would be different and the returncode would be 😎 so it seems like there is some downstream resource the export is trying to connect to. A special case that may explain the rc=0 you see. Also one I may not be able to help with.

I do know we have situations where the reverse is happening: ExportPackage fails but no error message in the logs. Usually when a flow is corrupted (which happens all too often). But that won't help you either. Just to confirm ImportPackage and ExportPackage are somewhat problematic.

gwootton
SAS Super FREQ

It sounds like the concern here is that the return code for the ExportPackage application may still be zero even if a warning or error is encountered.

Perhaps instead of using your logic testing against $?, you test against the contents of the log file. For example:

ExportPackage -profile "SASAdmin" -package /tmp/package.spk -objects "/User Folders/sasdemo" -includeDep -disableX11 -log /tmp/checkerr.log

err=$(grep -cE '(WARN|ERROR|FATAL)' /tmp/checkerr.log)

if [ "$err" =  '0' ]

then

echo "Export completed successfully."

else

echo "Export failed. See /tmp/checkerr.log for more details."

fi

--
Greg Wootton | Principal Systems Technical Support Engineer
Nivas88
Calcite | Level 5
Thank you so much. This helps

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
  • 5 replies
  • 567 views
  • 1 like
  • 3 in conversation