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

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--
-----------------------------------

Replies are listed 'Best First'.
Re: Re: Re: Re: Connect:Direct?
by nimdokk (Vicar) on May 21, 2003 at 20:08 UTC
    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--
      -----------------------------------
      
        That was our conclusion as well. It works just fine from the Korn Shell script. I suspect that the error message about the pend is a red herring. I suspect the problem lies earlier in commands, or in how it is running. We're going to keep at it because at least with this we are getting better error messages than we were (which is to say none at all) when running from a Perl Module.

        Thanks though. At least its giving me a direction to work in.

        "Ex libris un peut de tout"