Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Creating FTP Script for MVS

Posted on 2005-03-14
Medium Priority
Last Modified: 2012-06-22
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
Question by:Coghan
  • 3
  • 2

Accepted Solution

DaGo21 earned 1000 total points
ID: 13536425
@echo off

open MVS
echo open MVS >FTP.txt
echo USERNAME>>FTP.txt
echo PASSWORD>>FTP.txt
echo cd ToFolder>>FTP.txt
echo lcd c:\data>>FTP.txt
echo Binary>>FTP.txt
echo bye>>FTP.txt

ftp -s:FTP.txt >>c:\data\FTP.Log

REM if exist c:\data\NI*.* goto end

This batch file will first generate a generic TXT file with the commands.
The > will overwrite the TXT file, >> will add.  Add your own lines you need

The FTP -s:FTP.TXT will execute FTP with the input from the file.  The >> behind it will
send the output to a log file so you can read the status later.


Author Comment

ID: 13537828
I'm kind of halfway there.  When I originally did it, it got far enough to say that the login failed.  Now if I can only figure out what I did the first time.  I may have misinterpreted what you wanted me to do.  Please be patient

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.


Author Comment

ID: 13538137
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'?

Author Comment

ID: 13538163
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.  

Expert Comment

ID: 13542502
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.


Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just about everyone has an old PC laying around.  Ask anyone in the IT industry, whether they are a professional or play in it as a hobby.  From outdated Desktops to cheap "throwaway" laptops, they are all around and not as hard to "fix up" as you m…
I don't know if many of you have made the great mistake of using the Cisco Thin Client model with the management software VXC. If you have then you are probably more then familiar with the incredibly clunky interface, the numerous work arounds, and …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question