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.
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
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
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.
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.
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
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
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.
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
Just use CPYTOIMPF command. No FTP needed.
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
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.
i used your example, bob.
only problem is i get "550 Request rejected."
FTPUSER FTPPASS
put bretfiles/xferfile /mydir/xfer.csv
quit
Sarge,
Do a WRKREGINF command and see if there's an FTP exit program that could be rejecting your request.
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.
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
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.
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).