Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 871
Honus Wagner Avatar asked May 18 '26 08:05

Honus Wagner


1 Answers

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>
like image 155
PeskyGnat Avatar answered May 21 '26 09:05

PeskyGnat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!