View previous topic :: View next topic
|
Author |
Message |
IndianBlues
New User
Joined: 23 May 2006 Posts: 6 Location: Cincinnati
|
|
|
|
I'm getting or pulling different files from a remote server through FTP process. Before pulling these files I need to check for any duplicate files. If I find any duplicate files I should stop further processing and resolve duplicate files issue. So, if RC on the duplicate files is zero, i'm executing IDCAMS to set MAXCC to 16 which further stops job execution. So, when duplicate files are not found then job execution continues. In this case I cannot use COND on subsequent steps. I can only check for previous step condition code only. My tech lead wants this to be done in a different way. He wants me to check for FTP return code. I did some research and FTP return codes are in XXyyy format where XX depends on subcommand and yyy are reply codes. I can also use an EXIT=nn parameter but any error returns nn value. Is there any way of checking for FTP return codes in JCL? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello and welcome to the forum,
No. All jcl can do is execute programs.
Quote: |
Before pulling these files I need to check for any duplicate files. If I find any duplicate files I should stop further processing |
I don't believe you would use ftp to do this.
If you have a list of files, you could determine if they exist, but htis has nothing to do with ftp. . . |
|
Back to top |
|
|
IndianBlues
New User
Joined: 23 May 2006 Posts: 6 Location: Cincinnati
|
|
|
|
Well main issue here is checking for return codes on subsequent job steps. I could use LS to check for duplicate files but if the files are not there then step return code is a non zero value. So, I cannot use site specific standards of COND=(0,LT) on further steps. So, tech lead wants me to check for FTP return code than step return code. Any idea on how to check for FTP return codes in a job. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
You need to take some time and more clearly present what you want to do.
It is unclear where you need to check the existence of the files. On the mainframe or some other system? If you know the file names you intend to "pull" from some remote to the mainframe and your concern is if they have already been transmitted, i see no need for ftp to check anything. This can all be done on the mainframe with utilities.
You mention "checking for return codes on subsequent job steps". What would you check?
If i understand what you want to do, you could check for duplicates before ever running any ftp - but i may completely misunderstand
As i mentioned before, ftp codes are not available to COND= processing. |
|
Back to top |
|
|
MBabu
Active User
Joined: 03 Aug 2008 Posts: 400 Location: Mumbai
|
|
|
|
It seems like you are already dropping into Unix (omvs) to use the ls command so why not just do everything from within Unix. Assuming the file names are the same on both the remote server and your unix directory, you can use a simple shell script. Of course, in production you may want to add a few bells and whistles (like not having the password in the script, saving the FTP output somewhere, etc), but basically this type of thing shoud do:
Code: |
#!/bin/sh
# protect command file in case it is left behind by an error
[ ! -f ftpcmds ] || rm ftpcmds
umask 177
# login code for the ftp server
echo yourid > ftpcmds
echo yourpasswd >> ftpcmds
# set up for downloads (directory, transfer mode, etc)
echo bin >> ftpcmds
echo cd /srcdir >> ftpcmds
# add nonexistent files as 'get' commands
[ -f file1 ] || echo get file1 >> ftpcmds
[ -f file2 ] || echo get file2 >> ftpcmds
# termination, ftp invocation and cleanup
echo quit >> ftpcmds
ftp remote.server.name < ftpcmds
rm ftpcmds |
|
|
Back to top |
|
|
MBabu
Active User
Joined: 03 Aug 2008 Posts: 400 Location: Mumbai
|
|
|
|
I don't know why I used a file in that last example. I wasn't thinking straight and the edit timeout expired before I could change it. This simplified version should work without the command file (removed comments for brevity):
Code: |
#!/bin/sh
LOCALDIR=/your/download/directory
(
echo yourid
echo yourpswd
echo bin
echo cd /somedir
echo lcd $LOCALDIR
[ -f $LOCALDIR/file1 ] || echo get file1
[ -f $LOCALDIR/file2 ] || echo get file2
echo quit
) | ftp remote.server.name |
|
|
Back to top |
|
|
IndianBlues
New User
Joined: 23 May 2006 Posts: 6 Location: Cincinnati
|
|
|
|
Thanks to all your help. I should have presented my case in a better way. Anyway, this is what we're doing
Get files from a remote server to clients mainframe on a daily basis. Once we pull these files we process them and then connect back to remote server to delete files that we processed. It is our responsibility to delete files that are processed. If in any case files are not deleted on the remote server, vendor will NOT delete them but instead place files with .001 extension. With this there will be duplicate files on the remote server. So, we need to first checking for presence of duplicate file. I used LS to check for existence of duplicate file. If file is present (RC=0) then job execution is stopped by executing IDCAMS and setting MAXCC=16. If file is not present (RC=70) then we should continue with our processing. Since RC is 70 is there a way in JCL to reset this to RC to zero. I tried using IDCAMS to reset it but this didn't work. I want to reset this RC to zero so that I can use COND=(0,LT) on further steps. Otherwise, I can only test for condition code from previous step.
One other important issue, When I check for duplicate files and if files are found then IDCAMS is executed to set MAXCC=16 otherwise it executes further steps. Well, it should continue only when files are not found (RC=70) and any other cases like transmission failure, etc. should make the job abend as usual.
So, please let me know if there is a way to check for FTP return codes (not step RC) or is there a way to reset job step RC to zero or any better way of doing the above process. |
|
Back to top |
|
|
MBabu
Active User
Joined: 03 Aug 2008 Posts: 400 Location: Mumbai
|
|
|
|
This sounds like a much more complicated process than simple JCL can or should handle. I'd suggest writing a Rexx program to do this. Then you have full control of everything. You can check return codes, redirect FTP output to files you can read to get the return codes from individual FTP commands (and to get file lists), invoke FTP multiple times, clean up, and do whatever else you need to do. You might need to learn a little about Unix and invoking unix commands from Rexx running under TSO or running Rexx in Unix, but its a useful set of skills.
This is a case of using the right tool for the job. JCL can only start programs and skip other programs. Trying to get it to perform business logic is way outside its purpose. |
|
Back to top |
|
|
|