Coghan
asked on
Creating FTP Script for MVS
I currently have the weekly task of downloading a series of flat files from the mainframe to text files that get pulled into MS-ACCESS for some reporting. Lots of typing and a waste of my time. What I want to do is create a script to do this for me as the file names going in and coming out are always the same. I'm thinking some kind of .bat file, but I will admit that I haven't done anything of this sort in a long long time.
Currently, I run FTP MVS from the Start>Run menu. It prompts user id and password. Then I type in something similar to:
GET 'NXXX.TESTO.MYFILE' C:\DATA\MYFILE.TXT and then repeat that line for each file, over and over. There has to be a better way.
Thanks! -- Coghan
Currently, I run FTP MVS from the Start>Run menu. It prompts user id and password. Then I type in something similar to:
GET 'NXXX.TESTO.MYFILE' C:\DATA\MYFILE.TXT and then repeat that line for each file, over and over. There has to be a better way.
Thanks! -- Coghan
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Okay, duh.. I figured it out. You didn't mean for ME to open MVS.. you meant that 'open MVS' should be in the script. I got it. Seems to be working except it all comes out in one long illegible string, not in a text format. Should I take the line out that says 'binary'?
ASKER
I changed binary to text and it is perfect. I was a little slow on the uptake but it started fitting into place. I haven't written scripts in about 15 yrs so I have forgotten a lot. Thanks so much.
No worries, glad it all worked out. Funny to hear that MVS is still being used ;-)
Indeed all commands should be copied into a notepad file, saving it as ftpmvs.cmd (or similar) and run it. Of course you can do them 1 by 1 from the command line but that's still lots of work.
1 tip, you might want to add a line after the FTP -S command saying:
echo. >ftp.txt
del ftp.txt
This will overwrite the ftp.txt file and then delete it. Just to protect your password.
Enjoy
Indeed all commands should be copied into a notepad file, saving it as ftpmvs.cmd (or similar) and run it. Of course you can do them 1 by 1 from the command line but that's still lots of work.
1 tip, you might want to add a line after the FTP -S command saying:
echo. >ftp.txt
del ftp.txt
This will overwrite the ftp.txt file and then delete it. Just to protect your password.
Enjoy
ASKER
1) I went to start>run and entered CMD to get to the command line.
2) Typed echo off and hit enter
3) Entered each of these lines (note, to open ftp I have to use 'ftp mvs')
echo ftp mvs>ftp.txt
echo myuserid>>ftp.txt
echo mypasswd>>ftp.txt (for user id and password I entered the real thing, not the words I put here)
echo cd ToFolder>>ftp.txt (I wasn't sure what to do here, but I'm not sure I would want to change my directory)
echo lcd c:\data>>ftp.txt
echo binary>>ftp.txt (not sure what this does, so I left it in there anyway)
echo get 'nxxx.testo.myfile' myfile.txt>>ftp.txt
echo bye>>ftp.txt
4) I entered ftp -s:ftp.txt>>ftp.log
It is logging, but it mostly is full of 'Invalid Command'. My guess is that I misinterpreted what you were trying to tell me.