Search code examples
powershellftpmainframejcl

PowerShell raw FTP


I am looking to use FTP to write a mainframe jobstream. To do that, I can connect to the mainframe via FTP and run these commands:

QUOTE TYPE E
QUOTE SITE FILETYPE=JES
PUT myjob.jcl

So, how would I do this in PowerShell? I have read plenty on standard FTP transfers, but I haven't seen anything about customizing the calls for prep.

Thanks for reading.

EDIT

Here is the solution I came up with, per the answer here and this article:

@echo off
echo user %1> ftpcmd.dat
echo %2>> ftpcmd.dat
echo QUOTE TYPE E>> ftpcmd.dat
echo QUOTE SITE FILETYPE=JES>> ftpcmd.dat
echo put %3>> ftpcmd.dat
echo quit>> ftpcmd.dat
ftp -n -s:ftpcmd.dat %4
del ftpcmd.dat

Usage:

C:\>fileup user123 pa$$word myfile.txt ftp.server.com

Solution

  • Could you use the -s switch for FTP and specify a file that contains your commands to run?

      -s:filename     Specifies a text file containing FTP commands; the
                      commands will automatically run after FTP starts.
    

    Then you can call this in PowerShell as

    ftp -s:<myscript> <host>