in reply to Re: Connect:Direct?
in thread Connect:Direct?

Will this capture output into a logfile? or Do you think it can easily be set to do so? I was looking at this in light of our needs and also the fact that system() only returns the exit status, not the output and we need to see the output, or at least the NDM process number(s) for our logs.

Replies are listed 'Best First'.
Re: Re: Re: Connect:Direct?
by physi (Friar) on May 20, 2003 at 12:26 UTC
    And here it comes:

    use strict; #### #Change this to your path to the binaries $ENV{NDMBINDIR}='/path/to/your/cdunix/ndm/bin'; my $hostfilename ='yourFilename'; my $localfilename ='yourFilename'; my $conditionname ='yourcondition'; my $wait_for_result = 1; $SIG{USR1} = \&ok; $SIG{USR2} = \&nok; $SIG{ALRM} = \&timeout; alarm(7200); #die after 2 hours # call the subfunction my $log = condirect($localfilename,$hostfilename,$conditionname); # do a endlessloop untill a USR1 or USR2 Signal is received, then end +the loop while ($wait_for_result){ sleep 5; } #The output from connect direct is in $log!!! print "LOG: $log\n"; ### # AND HERE ARE THE SUB's ### sub condirect { my $file = shift; my $hostfilename = shift; my $condition = shift; my $nocondition = $condition."E"; my $LV3FND=`date +%I%M%S%p`; my $WDATE=`date +%d%m`; return `/p/w11b/sp3bf/cdunix/ndm/bin/ndmcli -x << EOJ submit $LV3FND process snode=cdmvs_prod st01 copy from ( pnode dsn=$file sysopts=\":DATATYPE=BINARY:XLATE=NO:STRIP.BLANKS=NO +:\" ) ckpt=0K compress extended to ( snode dsn=$hostfilename DISP=(RPL,CATLG,DELETE) DCB=(DSORG=PS,LRECL=100,RECFM=VB) ) ifst01 if (st01 le 4) then st01ok run task snode (pgm=CTMCND) sysopts=\"'ADD COND $condition $WDATE'\" run job pnode sysopts=\"/usr/bin/kill -USR1 $$ \" else st01err run task snode (pgm=CTMCND) sysopts=\"'ADD COND $nocondition $WDATE'\" run job pnode sysopts=\"/usr/bin/kill -USR2 $$ \" eif pend; EOJ`; } sub ok { print "Connect Direct Status OK\n"; $wait_for_result = 0; } sub nok { print "Connect Direct Status NOK\n"; $wait_for_result = 0; } sub timeout { print "Connect Direct Status TEMED OUT!!!\n"; $wait_for_result = 0; }

    -----------------------------------
    --the good, the bad and the physi--
    -----------------------------------
    
      Have you run into any problems with this code? I suspect that there might be some discrepencies in versions of C:D. But when I attempted to run this code snippet, with appropriate modifications, we kept getting an error message of: :&KEYWD=pend:. Of course, when we run the it from a shell script, there is no problem. We aren't doing anything as elaborate as your code, simply copying a file from Unix to a Mainframe.

      If anyone has any thoughts on this message, it might be a help. Thanks.

      "Ex libris un peut de tout"

        No sorry, this is runing with no problem on our system.
        If I understand you right, the pend seemd to be the problem. And when you put all that in a shell script, it works with the pend statement in it ?

        Sorry no idea right now :-(

        -----------------------------------
        --the good, the bad and the physi--
        -----------------------------------
        
Re: Re: Re: Connect:Direct?
by physi (Friar) on May 19, 2003 at 21:38 UTC
    I think it couldt be possible to get the output in a logfile. I will check it tomorow and will give you an update, or probably a full working example code ;-)
    -----------------------------------
    --the good, the bad and the physi--
    -----------------------------------
    
      I was looking over your code sample some more and I think you could capture to STDOUT if you used backticks or simply do a redirect on the "commandline" like this:

      /path/to/your/cdunix/ndm/bin/ndmcli -x << EOJ >> $log_file
      I haven't tested this all out yet but it definitly looks promising so that I can finally work towards eliminating our Korn shell programs.