Connect:Direct UNIX Examples
From UNIX to UNIX
This process copies a file from Unix to Unix then submits a run task on snode to execute the Unix command cp:test1 process snode=Unix step1 copy from (file=/home/user/testunix pnode) to (file=/home/user/deleteme) subok run task snode sysopts="cp /home/user/testcp /home/usernew/testcp" pend ;
This process copies a file from Unix to Unix using symbolic variables to build the destination file name:
Test2 process snode=Unix &d1 = /home/user &d2 = testfile &d3 = &d1/&d2 step1 copy from (file=/home/user/testunix pnode) to (file=&d3 disp=rpl snode) pend;
From UNIX to WINDOWS
This process copies a file from Unix to Windows then executes a run task to submit a .bat file on Windows:test1 process snode=Windows step1 copy from (file=/home/user/testunix pnode) to (file=c:\temp\deleteme.txt disp=new) if1 if (step1 eq 0) then run1 run task snode (pgm=windowsNT/95) sysopts="pgm(c:\temp\test.bat)" eif pend ;
This process copies a file from Unix to Windows the executes a run task to delete a Windows file:
test2 process snode=Windows step1 copy from (file=/home/user/testunix pnode) to (file=c:\temp\testfile.txt disp=rpl snode) step2 if (step1 < 4) then run task snode (pgm=windowsNT/95) sysopts="cmd(del c:\temp\deleteme.txt)" eif pend;
This process copies a file from Unix to Windows and includes the current date within the destination file name:
test3 process snode=Windows step1 copy from (file=/home/user/testunix pnode) to (file=datei_`date +%y%m%d`.txt snode disp=rpl) pend ;
This process copies a file from Unix to Windows then executes a run task
to submit a script on Unix:
test4 process snode=Windows step1 copy from (file=/home/user/testunix pnode) to (file=c:\temp\deleteme.txt disp=rpl) if1 if (step1 eq 0) then subok run task pnode sysopts="/home/user/cdunix/ndm/src/okay" else subfailed run task pnode sysopts="/home/user/cdunix/ndm/src/failed" eif pend ;
This process copies a file from Unix to Windows then executes a run task to submit a .bat file on Windows using UNC name for the network drive:
test5 process snode=Windows step1 copy from (file=/home/user/testunix pnode) to (file=c:\temp\deleteme.txt disp=rpl) if1 if (step1 eq 0) then run1 run task snode (pgm=windowsNT/95) sysopts="pgm(\\\Wserver\temp\test.bat)" eif pend ;
From UNIX to OS/390
This process copies a file from Unix to OS/390:test1 process snode=Os390 step1 copy from (file=/home/user/testunix pnode) to (file=TEST.FILE.COPY disp=new dcb=(dsorg=ps,lrecl=30,recfm=fb,blksize=3000)) pend ;
This process pulls a file from OS/390 to Unix then executes a run task to delete the OS/390 file:
test2 process snode=Os390 step1 copy from (file=TEST.FILE snode) ckpt=no to (dsn=/home/user/testunix disp=rpl sysopts=":datatype=text:xlate=yes:" pnode) step2 if (step1 < 4) then run task snode (PGM=DMRTDYN) sysopts="C'ALLOC DSN=TEST.FILE,DISP=(OLD,DELETE)', F'-1', C'UNALLOC DSN=TEST.FILE' " eif pend;
This process copies a file from Unix to OS/390 specifying a translation table different from the default one:
test3 process snode=Os390 step1 copy from (file=/home/user/testunix pnode sysopts=":xlate.tbl=/home/user/testtrans.xlt:") to (file=TEST.FILE.COPY disp=new) pend ;
This process executes a run task that invokes DMRTSUB program to submit a job on OS/390 passing a parameter:
test4 process snode=Os390
step1 run task (PGM=DMRTSUB)
sysopts="'DSN=TEST.LIB(JCL1),DISP=SHR',
'file1 TEST.FILE1'"
snode
pend ;
This process submit a process on OS390 passing two symbolic parameters:
test5 process snode=Os390 step1 submit file=TEST.LIB(TESTPROC) &FILEIN=/home/user/testunix &FILEOUT=TEST.FILE subnode=snode pend ;
From UNIX to OS/400
This process copies a file from Unix to OS/400:test1 process snode=Os400 step1 copy from (file = /home/user/testunix pnode) to (file = lib1/filetest disp = new sysopts="TYPE(MBR) RCDLEN(80)") pend;
This process executes a run task on OS/400 to call a program:
test2 process snode=Os400 step1 run task (PGM=AS400) sysopts="CMD(CALL PGM(library/program) PARM(parameter))" snode pend;
This process executes a run task on OS/400 to delete a member of a file:
test3 process snode=Os400 step1 run task snode (pgm = AS400) sysopts="RMVM FILE(LIB/FILE) MBR(TESTUNIX)" pend;
From UNIX to VMS
This process copies a file from Unix to Vms, then pulls a file from Vms to Unix and executes a run task to delete the VMS file:test1 process snode=Vms step1 copy from (file=/home/user/testunix sysopts=":datatype=text:xlate=no:" pnode) ckpt=1k to (dsn=DISK$SUP:[TECH1]TEST.DAT disp=rpl snode) step2 copy from (file=DISK$SUP:[TECH1] TEST.DAT snode) ckpt=no to (dsn=/home/user/testunix disp=rpl sysopts=":datatype=text:xlate=no:" pnode) step3 if (step2 < 4) then run task snode (PGM=VMS) sysopts="cmd='delete DISK$SUP:[TECH1] TEST.DAT;'" eif pend;
From UNIX to TANDEM
This process copies a file from Unix to Tandem, then pulls a file from Tandem to Unix and executes a run task to delete the Tandem file:test1 process snode=Tandem step1 copy from (file=/home/user/testtandem pnode) to (file=$USER.TEST.TANTEST disp=rpl sysopts="'set code 0' 'set type u' 'set block 4096'" snode) step2 copy from (file=$USER.TEST.TANTEST disp=shr snode) to (file=/home/user/testfile pnode) step3 if (step2 < 4) then run task snode (pgm = fup) sysopts="PURGE $USER.TEST.TANTEST!" eif pend;
Miscellaneous
Calling Connect:Direct from within a shell script:
CDDIR=/home/user/cdunix NDMAPICFG=$CDDIR/ndm/cfg/cliapi/ndmapi.cfg export NDMAPICFG SNODE=Unix $CDDIR/ndm/bin/direct -x << EOJ1 submit maxdelay=unlimited test1 process snode=$SNODE step1 copy from (file=/home/user/testunix pnode) to (file=/home/user/delete.me snode) pend; quit; EOJ1 SAVE=$? if [[ $SAVE > 0 ]] then echo $SAVE echo "Error occurred." exit 1 fi echo "Copy completed successfully." exit 0
Using Connect:Direct for Unix pipe/io functionality
Test2 process snode=Unix step1 copy from (file = "tar cf - *.cd" sysopts = ":pipe=yes:datatype=binary:") to (file = /tmp/test.tar) step2 copy from (file = /tmp/test.tar) to (file = "mkdir /tmp/tar_tst ; cd /tmp/tar_tst ; tar xf -" sysopts = ":pipe=yes:datatype=binary:") step3 copy from (file = "tar cf - *.cd" sysopts = ":pipe=yes:datatype=binary:") to (file = "mkdir /tmp/tar_tst2 ; cd /tmp/tar_tst2 ; tar xf -" sysopts = ":pipe=yes:datatype=binary:") pend;