Midrange News for the IBM i Community


Posted by: bret myrick
FTP to IFS
has no ratings.
Published: 16 Apr 2014
Revised: 21 Apr 2014 - 3651 days ago
Last viewed on: 19 Apr 2024 (15171 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 to IFS Published by: bret myrick on 16 Apr 2014 view comments(16)

hi all,

 

i am trying to automate FTP to the IFS.

i created the script and everything (except the part that works) just like the IBM example.

Pgm

OvrDbf File(InPut) ToFile(FtpCmd)
OvrDbf File(OutPut) ToFile(FtpResult)
FTP RmtSys('192.168.1.2')

DltOvr File(InPut)
DltOvr File(OutPut)

EndPgm

File FtpCmd is 100 Bytes in length
FTPUSER PASSWORD
Site NameFmt 1
Put BretFiles/XferFile \\AS400\Folder\XferFile.CSV
Quit

Something obvious is missing, but i am missing the obvious.

BTW, purchasing CozTools is not an option at this time, or I would have done that.

All help is appreciated.

-Bret

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

COMMENTS

(Sign in to Post a Comment)
Posted by: Ringer
Premium member *
Comment on: FTP to IFS
Posted: 10 years 4 days 3 hours 40 minutes ago
Edited: Wed, 16 Apr, 2014 at 15:31:15 (3656 days ago)

Hi Sarg! 

FTP already knows the system you are FTPing to. Try one of these:

Put BretFiles/XferFile \Folder\XferFile.CSV

Put BretFiles/XferFile /Folder/XferFile.CSV

And you may need to stick 'user' in front of the userid and password. I forget.

user FTPUSER PASSWORD

Chris Ringer

Posted by: Bret
Premium member *
Comment on: FTP to IFS
Posted: 10 years 4 days 3 hours 23 minutes ago

thanks ringer.

did not work, though.

keep getting message 550 Request rejected, when using forward slashes.

get message 501 Unknown extension in database file name, when using back-slashes.

been a few years since i had to FTP other than manually. don't remember it being such a chore.

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: FTP to IFS
Posted: 10 years 4 days 55 minutes ago
Edited: Wed, 16 Apr, 2014 at 18:14:35 (3656 days ago)

Is the example in your message here correct? You have two back slashes in front of the AS400.

Put BretFiles/XferFile \\AS400\Folder\XferFile.CSV

You also don't have anything in front of your local file. So it will default to /home/sarge (or whatever your HOME directory is). 

If you do NOT include  forward slash, it defaults to /qsys.lib/whatever...

If you are in your current directory already, then just do this:

Put /BretFiles/XferFile /AS400/Folder/XferFile.CSV

You may need to do a LCD to the folder where your local file is located. But if you're coming off the root directory, then what I've shown you will work.

 

 

Posted by: clbirk
Premium member *
Comment on: FTP to IFS
Posted: 10 years 3 days 22 hours 24 minutes ago

questions:

 

are you trying to ftp from the "as/400" to the ifs on the same as/400  OR are you trying to ftp from like say a pc, to the ifs on an as/400  or are you trying to ftp from one as/400 to the ifs on another as/400

 

Here is why I ask?  If you are trying to ftp from the same as/400 to the ifs, why not simply use copy import or copy stream command or write a program to directly write into the ifs?  I asssume by the overrides, you aren't doing the pc to ibm i ifs.

On the pc, if I am doing a canned bat to ftp to the ibmi (ifs or qsys), I would typically do:

 

open xx.xx.xx.xx  (ip address of device)

user

pw       

cd

lcd

put  xxxxxxxxxxx   xxxxxxxxxxxxxx

quit

 

I don't fart around with the namefmt 1 which everyone acts like it is the greatest thing since peanut butter. I think it is stupid.  I also don't ftp much to the IFS, (amall percentage of the files), most go right into the library.

 

if you are doing it on an ibmi to an ibmi (same or different0, have you opened up the interactive FTP command, and tried your put command, etc. because if it doesn't work there, it isn't going to work elsewhere.

 

I mean if you are doing it from a pc to the ifs, then map a drive, and simply copy it into the folder if you want.

 

Let me give you a few other approaches at least to consider...

Consider writing a webservice and running it on the ibmi, even if on the same box, you can call the webservice, transfer the file and let the webservice control where it goes.

That is, if you have php installed on the ibmi, you can write s simple php "page" that you can call from rpg (like with iscokets or httpapi or geturi) and dump the stuff, for that matter, you could probably do it all with a php page and just call the page and do the transfer.

There is usually more than one way to skin a cat. Some are not pretty, but they work.

 

chris

T

 

 

 

Posted by: Ringer
Premium member *
Comment on: FTP to IFS
Posted: 10 years 3 days 10 hours 40 minutes ago

I believe the PF path needs to be IFS "PC like" too for NAMEFMT 1. 

Put /qsys.lib/BretFiles.lib/XferFile.file/XferFile.mbr /Folder/XferFile.CSV

Chris Ringer

Posted by: DaleB
Premium member *
Reading, PA
Comment on: FTP to IFS
Posted: 10 years 3 days 9 hours 18 minutes ago

You do not need to put anything in the beginning of the FTPUSER PASSWORD line, but some servers might require you to put FTPUSR and PASSWORD on separate lines. (Don't really think this happens anymore, but we did have that situation once a long time ago.)

Forward slashes versus backslashes is server dependent. Windows uses backslashes. Unix uses forward slashes. Not sure how tolerant they are if you get that wrong. Our IFS accepts it either way, as long as you're consistent within any given path string.

Have you tried the same commands interactively? I don't think you can emulate the user/password part, but you could confirm the other statements. Interactive or batch, might be worth throwing a VERBOSE after the user/password line to see if you can get any more details.

Posted by: Bret
Premium member *
Comment on: FTP to IFS
Posted: 10 years 3 days 8 hours 57 minutes ago

i am going from the same as/400 to the ifs on the same /400.

i am running the command from the /400 side, trying to get the file to go to the ifs directory.

still no GOOD luck.

 

-bret

Posted by: Ringer
Premium member *
Comment on: FTP to IFS
Posted: 10 years 3 days 8 hours 48 minutes ago

Just use CPYTOIMPF command. No FTP needed. 

Posted by: Bret
Premium member *
Comment on: FTP to IFS
Posted: 10 years 3 days 8 hours 17 minutes ago

the cpytoimpf is the obivous option, but there are a few things on the horizon that will require FTP.

i created a MCP ("Master Control Program/Micro Chess Program) being a fan of the original TRON movie.

based on the the parms you pass it, it will send .pdf reports as email, send files to the ifs, or run a command, based on the command(s) in the file.

want to do the same thing with FTP. i know i've been away to afghanistan and iraq a lot in the past 13 years, but i've never had problems with ftp'ing from the /400. web service is out, only because of the others who work here who don't understand the construct of such.

 

-bret

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: FTP to IFS
Posted: 10 years 3 days 8 hours ago
Edited: Thu, 17 Apr, 2014 at 11:09:11 (3655 days ago)

I had no trouble using this PUT statement. Note the direction of quantity of the slashes.

put aiddata/custinfo /home/cozzi/whatever.csv                             
229 Entering Extended Passive Mode (|16791|).                           
150-NAMEFMT set to 1.                                                     
150 Sending file to /home/cozzi/whatever.csv                              
226 File transfer completed successfully.                                 
328416 bytes transferred in 0.025 seconds. Transfer rate 12934.538 KB/sec.
Posted by: Bret
Premium member *
Comment on: FTP to IFS
Posted: 10 years 3 days 6 hours 14 minutes ago

i used your example, bob.

only problem is i get "550 Request rejected."

FTPUSER FTPPASS

put bretfiles/xferfile /mydir/xfer.csv

quit

 

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: FTP to IFS
Posted: 10 years 3 days 5 hours 59 minutes ago

Sarge,

 

Do a WRKREGINF command and see if there's an FTP exit program that could be rejecting your request.

Posted by: Bret
Premium member *
Comment on: FTP to IFS
Posted: 10 years 3 days 5 hours 3 minutes ago

thre are many exit programs. none named in a fashion that says they have to do with FTP, or not.

even the text is somewhat ambiguous.

will have to wait until tuesday to get a answer on which is what.

Posted by: Ringer
Premium member *
Comment on: FTP to IFS
Posted: 10 years 3 days 4 hours 26 minutes ago
Edited: Thu, 17 Apr, 2014 at 15:03:36 (3655 days ago)

As I recall, if the user profile does not have *ALLOBJ authority, the user needs specific authority to do PUT/GET/etc.

Type WRKFCNUSG QIBM_QTMF_CLIENT*  then find the one for "Send Files", 2, and add your user profile or set the default to *ALLOWED (probably safer to add user profiles since *ALLOWED is like "*PUBLIC *USE").

Chris Ringer

Posted by: DaleB
Premium member *
Reading, PA
Comment on: FTP to IFS
Posted: 10 years 2 days 10 hours 19 minutes ago

FTP from a server to itself is almost never needed. E-mail as PDF vs. copy to IFS vs. execute commands in the file are going to require separate code paths anyway. In the case of copying to IFS, it comes down to what kind of data is in BretFiles/XferFile, and what do you want the ouput file to look like?

If you really want a CSV, then CPYTOIMPF is probably the best choice, followed by roll your own with a program that reads the file and writes directly to IFS using stream file APIs. If you pursue the FTP path, you will not get a CSV; FTP doesn't do that.

Posted by: clbirk
Premium member *
Comment on: FTP to IFS
Posted: 9 years 11 months 30 days 58 minutes ago

expanding on what dale said, if you have something special (not a csv file, etc), then simply using cpytostmf works just fine also. I dump hundreds if not thousands of files a day into IFS, and even onto a "remote IFS" (using Qserver.400).