Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Connect:Direct?

by physi (Friar)
on May 19, 2003 at 09:02 UTC ( #259097=note: print w/ replies, xml ) Need Help??


in reply to Connect:Direct?

AFAIK, there's no module available for that, I played around and got that sub, which does the main thing for me:

sub condirect { my $file = shift; my $hostfilename = shift; my $snode = shift; my $condition = shift; my $nocondition = $condition."E"; #--------------------------------------------------------------------- +--- # Environment fuer ConnectDirect setzen #------------------------------------------------------------- +----------- $ENV{NDMLOGDIR}='PATH TO WHERE YOUR C:D IS'; $ENV{NDMPROCDIR}='PATH TO /cdunix/ndm/process'; $ENV{NDMBINDIR}='PATH TO /cdunix/ndm/bin'; $ENV{NDMAPICFG}='PATH TO /cdunix/ndm/cfg/cliapi/ndmapi.cfg'; my $WDATE=`date +%d%m`; my $jobname='Testjob'; return system("/path/to/your/cdunix/ndm/bin/ndmcli -x << EOJ submit $jobname process snode=$snode 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"); }
As you can see, the sub sends a kill-signal to itselfe, USR1 or USR2.
Then you can do something, if connectdirect fails or just ends OK.
This is working for about 2 years now, with no problems.

Hope this helps.

-----------------------------------
--the good, the bad and the physi--
-----------------------------------


Comment on Re: Connect:Direct?
Download Code
Re: Re: Connect:Direct?
by nimdokk (Vicar) on May 19, 2003 at 16:45 UTC
    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.
      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.
      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"

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://259097]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2014-08-21 12:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (134 votes), past polls