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