3

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
Honus Wagner
  • 2,830
  • 13
  • 44
  • 61

2 Answers2

3

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>
PeskyGnat
  • 2,454
  • 19
  • 22
  • I came to the same conclusion. I actually created a .bat file to handle this. See my edit for the solution I came up with. – Honus Wagner Jun 08 '11 at 15:20
0

If you're comfortable with .NET and want to do it programatically, there is a similar question/answer here:

Upload files with FTP using PowerShell

It pretty much goes comes down to using a System.Net.FtpWebRequest for the job. At first glance it seems fairly straight forward.

Community
  • 1
  • 1
Scott Saad
  • 17,962
  • 11
  • 63
  • 84
  • Scott, I appreciate your feedback, but System.Net.FtpWebRequest does not have room for "arbitrary" calls. The QUOTE TYPE E and QUOTE SITE FILETYPE=JES are not supported via FtpWebRequest. – Honus Wagner Jun 08 '11 at 15:18