Midrange News for the IBM i Community


Posted by: sarge
Citizen/Soldier
U.S. Army
United States
FTP
has no ratings.
Published: 06 Jan 2015
Revised: 09 Jan 2015 - 3392 days ago
Last viewed on: 22 Apr 2024 (4216 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

FTP Published by: sarge on 06 Jan 2015 view comments(7)

okay. having one of those days....weeks, that is.....where i cannot get something simple to work.

i want to FTP a file from my local drive to the iSeries.

am on v5r3, using a file for the script, but cannot get the file to transfer. running under my profile which has *secofr authority.

runs fine from the Windows prompt window, but want to run in CLLE.

somebody kick me in the behind and help, while i go bang my head on the wall.

thanks.

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: FTP
Posted: 9 years 3 months 17 days 23 hours 13 minutes ago

Hi Sarge,

I'm a bit confused as to the environment...

Are you trying to run an FTP !--script-- on the 400, and use it to transfer a file to your 400 from your PC?

"Local drive" is the ambiguous term for me.

In your CL program, did you override the INPUT file to your FTP !--script-- before running the FTP command?

Posted by: starbuck5250
Premium member *
Comment on: FTP
Posted: 9 years 3 months 17 days 5 hours 15 minutes ago

FTP is one of those terms that almost always needs clarification.  There are two kinds of FTP: FTP server and FTP client.  When you open a command window on your PC and you type ftp you are starting an FTP client, connecting to your IBM FTP server.  You're probably doing a put to push the file from the PC to IBM i.

If you want to do something similar using a CL program, you will be reversing the roles.  The IBM server will be the client and the PC will be the server, and you would be doing a get to pull the file from the PC to IBM i.  That means you will need to be running an FTP server on your PC, which doesn't happen out of the box.

Generally speaking, I find it easier to map a network drive from an IBM i IFS directory so that any of your PCs can simply save a file to that directory and then any IBM i process can get at it without having to do anything special to the PC.  CPYFRMSTMF, CPYFRMIMPF, the C read() API or even FTP (to *LOCALHOST) would work to move the file from the IFS to DB2.

Posted by: sarge
Premium member *
United States
Comment on: FTP
Posted: 9 years 3 months 17 days 4 hours 4 minutes ago
Edited: Wed, 07 Jan, 2015 at 10:37:03 (3394 days ago)

i have a !--script-- file on the iSeries.

I am trying to receive a file from my local or ifs drive to the iSeries. I will also want to send a file to the local drive or ifs at some point.

the FTPIN file on the iSeries looks like

namefmt 1

bmyrick mypwd

put c:\folder\file.txt bretlib/file (repl

quit

Posted by: Ringer
Premium member *
Comment on: FTP
Posted: 9 years 3 months 17 days 3 hours 56 minutes ago

namefmt 1 means use the IFS root system (PC files) instead of DB2. It does not mean use the C: drive. Save the file to the IFS not the C: drive. 

Chris Ringer 

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: FTP
Posted: 9 years 3 months 17 days 2 hours 48 minutes ago
Edited: Wed, 07 Jan, 2015 at 14:49:29 (3394 days ago)

You can't use qualified object names and NAMEFMT 1

Switch it to:

put /qsys.lib/bretlib.lib/file.file (Replace

Having said, that you didn't explicitly answer my request to define the term "local drive" but you example code shows me that "local drive" = "PC hard drive".

Unless you have an FTP server running on your PC and have the IP or DNS name for your PC setup, you ain't gonna get there.  The other way round work (when running the FTP !--script-- from the PC) because the 400 has an FTP server running.

Posted by: sarge
Premium member *
United States
Comment on: FTP
Posted: 9 years 3 months 17 days 2 hours 42 minutes ago

right now the file is on a local (c:) drive. it's just a flat file we receive and that i want to ftp via CLLE, so the job can be automated.

been away for awhile (again) and it's the simple crud that i forget.

Posted by: DaleB
Premium member *
Reading, PA
Comment on: FTP
Posted: 9 years 3 months 15 days 6 hours 58 minutes ago
Edited: Fri, 09 Jan, 2015 at 07:43:41 (3392 days ago)

As has already been mentioned, seems like it would be simpler to move your PC's file from C: to either the IFS, or to somehwere on your network where your CL can then grab it in whatever fashion.

That being said, if the file must be on the PC's C: drive, then you'll need an FTP server (also already mentioned) running on the PC. Check out FileZilla; it's an open source project at https://filezilla-project.org/. I'm sure there are others. FileZilla has two products, an FTP client, and an FTP server. I use the client all the time, but I have used the server product for personal things.

For what you're describing, your PC will need to run FileZilla server. The configuration is not terribly difficult; check out the FAQ. One thing you will have to reconcile is the FTP server maps actual disk locations, like your c:\folder, to an alias; e.g., /folder. Conceptually, this is similar to an NFS mount, an IFS share, or a Windows share. The share name is what clients see, and the physical directory structure is masked.

What that means to you is, the !--script-- that your CL invokes will not "get c:\folder\file.txt bretlib/file (repl"; instead, it will need the alias, "get /folder/file.txt bretlib/file (repl", where "/folder" at the beginning is the alias that you configure.