Again a similar thing in php - I look for a certain string in the output and
use that as a return code

$udtCmd="LANG=en_US.UTF-8;export LANGcd
/usr/ud/accounts/$account;/usr/ud71/bin/udt RUN $BP $prog";
$result = array();
exec( $udtCmd, &$result);
foreach ( $result as $v )
{

  if (substr($v,0,6)=="!stat="){
    $stat=substr($v,6,10);
  }
}




-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: 17 November 2008 15:09
To: u2-users@listserver.u2ug.org
Subject: Re: [U2] Setting return code when a Universe process terminates

We do something similar here.  In a UNIX shell script we call a Unidata 
sub and capture the output into a log file.

echo Running BP $udtProgram >> $logfilepath
$UDTBIN/udt<<EOD | tee -a $logfilepath
RUN BP $udtProgram -N
bye
EOD

Any output from the Unibasic program will be captured.  In this case we 
send it to the log and to standard output.  If you could limit the output 
of the Unibasic sub to only the values, or messages you wanted, you could 
use DISPLAY to return them.  A more  experienced *nix person might be able 
to tell you how to pipe the output to a variable, or possibly your perl 
program could use the standard ouput of the shell program.

Hope this helps.


> I'm trying to write some Universe programs that plug into an 
> existing perl framework. For this to work these programs need to set
> the standard unix exit code to different values when these programs 
> terminate. This will allow this framework to test for different 
> error conditions. (The equivalent test in a ksh script would be on 
> $?). What is the best way to make this work? Everthing I've tried 
> returns 0.

BRAD
>>I ended up using a shell script to call my UniBasic program and pass in 
a 
>>location and name of an ascii file. The program determines exit status 
and 
>>echoes it to the ascii file.

Charles Shaffer
Senior Analyst
NTN-Bower Corporation




[EMAIL PROTECTED]
Sent by: [EMAIL PROTECTED]
11/17/2008 07:20 AM
Please respond to u2-users

 
        To:     u2-users@listserver.u2ug.org
        cc: 
        Subject:        Re: [U2] Setting return code when a Universe process
terminates


Ian, I tried for a long time to figure out a way to do this entirely from 
within UD. Couldn't figure it out. I hit two walls. First, the exit code 
that nix receives is the status of the udt command. If you're program runs 

at all, you get a '0'. The second wall was when I tried setting an 
environment variable from within my code. The issue there is that shelling 

out starts a new shell that is closed as soon as you return to UD. The 
only way I could make it work was to echo a status code to an ascii file.

I ended up using a shell script to call my UniBasic program and pass in a 
location and name of an ascii file. The program determines exit status and 

echoes it to the ascii file. After the program completes, the shell script 

checks the contents of the ascii file and does an 'exit #'. I've had this 
working for a couple years with no issues. I'd be willing to discuss 
details off-list if you like.

Brad

> 
> I'm trying to write some Universe programs that plug into an 
> existing perl framework. For this to work these programs need to set
> the standard unix exit code to different values when these programs 
> terminate. This will allow this framework to test for different 
> error conditions. (The equivalent test in a ksh script would be on 
> $?). What is the best way to make this work? Everthing I've tried 
returns 0.

U.S. BANCORP made the following annotations
---------------------------------------------------------------------
Electronic Privacy Notice. This e-mail, and any attachments, contains 
information that is, or may be, covered by electronic communications 
privacy laws, and is also confidential and proprietary in nature. If you 
are not the intended recipient, please be advised that you are legally 
prohibited from retaining, using, copying, distributing, or otherwise 
disclosing this information in any manner. Instead, please reply to the 
sender that you have received this communication in error, and then 
immediately delete it. Thank you in advance for your cooperation.



---------------------------------------------------------------------
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
No virus found in this incoming message.
Checked by AVG - http://www.avg.com 
Version: 8.0.175 / Virus Database: 270.9.3/1786 - Release Date: 16/11/2008
19:58
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to