?
Solved

Creating FTP Script for MVS

Posted on 2005-03-14
5
Medium Priority
?
553 Views
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
0
Comment
Question by:Coghan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
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 get NXXX.TESTO.MYFILE>>FTP.txt
echo bye>>FTP.txt

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



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

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.

Enjoy
0
 
LVL 1

Author Comment

by:Coghan
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.

         
0
 
LVL 1

Author Comment

by:Coghan
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'?
0
 
LVL 1

Author Comment

by:Coghan
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.  
0
 
LVL 4

Expert Comment

by:DaGo21
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.

Enjoy
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Many people tend to confuse the function of a virus with the one of adware, this misunderstanding of the basic of what each software is and how it operates causes users and organizations to take the wrong security measures that would protect them ag…
In this article we will discuss all things related to StageFright bug, the most vulnerable bug of android devices.
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.

777 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