Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Direct Connect Question

by jmiklg (Initiate)
on Feb 02, 2011 at 17:30 UTC ( #885796=perlquestion: print w/replies, xml ) Need Help??

jmiklg has asked for the wisdom of the Perl Monks concerning the following question:

Does anyone know how I can pass a process number in a Run Job command. I'm trying to pass the process number that is running to a bat file that is being run via the Run Job command.

Replies are listed 'Best First'.
Re: Direct Connect Question
by roboticus (Chancellor) on Feb 02, 2011 at 17:39 UTC


    I don't recall ever hearing of a Run Job command. Perhaps you could add bit of information? If it's something you're executing from the command line, then if the Run Job command will accept it, just pass it on the command line. If it's a function, then perhaps the process ID is an argument you can pass to it.


    When your only tool is a hammer, all problems look like your thumb.

      This is kind of a "do nothing" that I wrote to try and test what I'm trying to accomplish. I'm trying to figure a way to pass the process number to the job (the bat file) The cdp file: /*BEGIN_REQUESTER_COMMENTS $PNODE$="ATLTECH04" $PNODE_OS$="Windows" $OPTIONS$="WDOS" END_REQUESTER_COMMENTS*/ LCLCOPY PROCESS &PNUMVAR=$PNUMBER$ COPYSTEP RUN JOB PNODE (DSN=wINDOWS) SYSOPTS="pgm(D:\P\LOCALCOPY.BAT) args(D:\MIKEG\INCOMING D:\MYTEMP\INCOMING &PNUMVAR)" PEND The contents of the bat file: COPY %1 %2.%3 Bottom line is, once I can figure out how to do it, I'm just trying to copy a trigger file called INCOMING from one directory to another one, and add an extension to the file name, which would be the process number that ran successfully on Direct Connect. The process above is what I'm playing with to try and figure out how to pass that process number along.


        In that case, then you'd just pass the process number in the args list, and then your batch file could get it. For example, given this as the batch file:

        @echo off rem rem do_nothing.bat <SrcDir> <DstDir> <ProcID> rem echo Source Dir: '%1' >D:\MYTEMP\JOB.OUT echo Dest Dir : '%2' >>D:\MYTEMP\JOB.OUT echo Process # : '%3' >>D:\MYTEMP\JOB.OUT

        So if your job starts the batch file properly, then after it executes, you should find the file D:\MYTEMP\JOB.OUT containing the argument values you passed in. So is your difficulty on the DOS/Win batch file side or in starting the job?


        When your only tool is a hammer, all problems look like your thumb.

Re: Direct Connect Question
by nimdokk (Vicar) on Feb 02, 2011 at 18:32 UTC
    I'm assuming you mean Connect:Direct? What are you trying to accomplish? Are you trying to transfer a file? read the logs? Are you using NDM?
      Yes, Connect:Direct is what I'm referring to. I'm trying to figure out how, within the cdp process file, to pass the process number that is running, to another application. For example, I have a process running that is transferring a file from the source node to a remote node. I want to be able to pass the process number that is doing the transfer, to another application.
        OK, this may or may not help. What you are using may behave differently from what we use. We use NDM (ndmcli). First thing is that we are capturing all the screen output to a temp file. This output includes the Process Number. What we then do is within a script run the ndmcli session and pass all the information to it using << for a "here" document in a system command. then, once that piece of the routine is finsihed, we parse the temp log file for the Process Number, store it in a variable which is then passed to a second invocation of the ndmcli so we can pull parse for Completion Code data so we know if the process worked or not. Please understand what we are doing is different from what you might be doing in that A) we run NDM on a Unix platform and B) we are doing a file transfer from Unix to a Mainframe (so there are different parameters/options for NDM). What follows is a function that I put into a custom Perl Module for my team to use so they don't have to recreate all this code every time. Also, a lot of this is based on some old code that I found that someone else wrote which I then converted from Korn Shell to use in Perl and some of it I don't quite understand but I can make educated guesses at what it is for. YMMV with the following code sample. I would suggest looking at it, if it helps, great, if not, sorry. You may also want to compare it against code samples in the C:D manuals (if you can lay your hands on them - I used to have a stack of old ones but they got purged in general office cleaning years ago). This code is mean to be run as a subroutine function from within a Perl script.

        sub run_ndm { # Set NDM Environment $ENV{NDMBINDIR}=File::Spec::Unix->catdir('/',"opt","cdunix","ndm","bin +"); $ENV{NDMAPICFG}=File::Spec::Unix->catfile('/opt',"cdunix","ndm","cfg", +"cliapi","ndmapi.cfg"); $ENV{PATH}='/bin:/usr/bin:/opt/cdunix/ndm/bin'; my ($file,$process,$dataset,$blocks,$reclength,$recform)=@_; my $log=File::Spec::Unix->catfile('/',"opt","CyberFusion","log","$proc +ess.ndm.log"); my $temp=File::Spec::Unix->catfile('/',"opt","CyberFusion","log","$pro +cess.temp"); my $pnum; my $return; $dataset="$dataset(+1)" if ($_[6] =~ /G/i); umask 0110; # Printing parameters to log file. print "-" x 30; print qq/ Running with the following parameters... Process: $process File Name: $file NDM File Name: $dataset Record Format(RECFM): $recform Record Length(LRECL): $reclength Block Size(BLKSIZE): $blocks /; print "-" x 30 . "\n"; # executing NDM process system("/opt/cdunix/ndm/bin/ndmcli -x << EOJ >> $log submit $process process snode=XXXXXXXX #snode is the node ID for the d +estination step01 copy from (file=$file sysopts=\":datatype=text:\" pnode ) compress extended to (file=$dataset DCB=(RECFM=$recform,LRECL=$reclength,BLKSIZE=$blocks,DSORG +=PS) SPACE=(CYL,(000050,0000020,),RLSE,,) snode disp=(NEW,CATLG,DELETE) ) step02 if (step01 gt 4) then run task sysopts=\"echo ** File not copied, Abnormal Termi +nation **\" goto stepend eif stepend run task sysopts=\"echo ** Job Ending **\" pend; EOJ"); $|=0; #flush the print buffers sleep 300; #sleep for 300 seconds - may need to be adjusted longer to +make sure that the NDM process is complete # Try to open the log file - may want to adjust this to not die if it +cannot open the file, but instead sleep for a # specified amount of time (say 60 seconds) to give the file time to t +ransmit open LOGFILE, "$log" or die "Cannot open $log. $!"; #once we get into the log file, we grab the process number to be used +in the status check later foreach my $line (<LOGFILE>) { chomp $line; if ($line =~ /mber/) { #pnum=substr($line,-5,5); $pnum=substr($line,36); }#close if }#close inner foreach close LOGFILE; # next we will fire up the ndmcli again and dump it out to a temporary + file. system("/opt/cdunix/ndm/bin/ndmcli -x << EOJ >> $temp select statistics pnumber=($pnum) detail=YES; q; EOJ"); $|=0; #flush the buffers # now that we have the status dumped to a temp file, we have to parse +it. # to find the Completion codes. open TEMP, "$temp" or die "Cannot open $temp. $!"; # Scan each line for "Ccode" # using backreferences on the 'ccode' line, pull out the return codes. # these return codes represent the source and destination completion c +odes for both ends of the process # Both sides are added together to get one number ($return). foreach my $line (<TEMP>) { chomp $line; if ($line =~ /Ccode/) { $line=~/\w+\s+.{2}(\w+)\s+\w+\s+.{2}(\w+)/; $return=$1+$2; }# }#close foreach close TEMP; unlink $temp or die "Cannot delete $temp. $!"; ## make sure $return is a valid number. If it is not a number, then se +t it to 1 to indicate an error condition. ## if $return is NOT defined, then set $return to 1 to raise an error +in the calling script. if ( ! defined $return) { $return=1; }#close if # finally we return to the main script and pass the value of $return b +ack to the main script for evaluation. # Doing this will require a modification to the scripts to properly ev +aluate $return. See template script for # details on doing this. return $return; }

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://885796]
Approved by broomduster
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2021-10-25 21:12 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (90 votes). Check out past polls.