Learn how to a build a cloud-first strategyRegister Now


How do I use a user exit program when invoking FTP?

Posted on 2009-02-10
Medium Priority
Last Modified: 2013-12-06

Does anyone know how I would specify a user exit program to be used when transferring a file via FTP to as400?

The as400 has a user exit program called e.g USEREXIT. How do I use it when transferring remotely via ftp in my shell script (see below for my current FTP code
ftp -n $HOST   <<END_SCRIPT > tmp/ftp.log
quote USER $USER
put $DIR/filename.csv

I'm new to scripting, ftp and have never used a user exit program so any help would be much appreciated, thanks
Question by:GlobexCorp
  • 3
LVL 27

Accepted Solution

tliotta earned 1000 total points
ID: 23605831

It's not clear if you're using the wrong words or the wrong concept.

An AS/400 allows "exit programs" to be assigned to various servers. FTP is one of those servers. But you don't call exit programs -- the FTP server calls them. Your script is unrelated to exit programs. If an exit program has been associated with a server, it will be called no matter what your script does.

So, can you rephrase your question? Are you looking for info on how to assign an exit program to the FTP server or are you looking for info on how your script might call a program when it runs?

Those are two different things.

Exit programs are generally assigned by system administrators in order to enhance security, to provide audit trails, to alter the environment (for all FTP connections), etc.

A script might call a program to run a function just for that single connection.

LVL 36

Expert Comment

by:Gary Patterson
ID: 23606171
Exit programs get called by a licensed program (OS, FTP, etc) when a particular event occurs.  Think of an exit point as a place in an OS program or utility where th eprogram "pauses" for a minute to see if you, the user, want to call a custom program.  The idea is that, instead of allowing users to modify OS programs, you instead give them an opportunity to have a custom program called when important points are reached, so that they canperform additional processing, validation , logging, etc.

Use the WRKREGINF command to view available registered exit points for various system facilities.

Exit programs are often used to provide an additional layer of security, for example limiting certain FTP operations, controlling the time of day FTP access is allowed, or imposing other restrictions.  The Exit program is generally passed a set of information regarding the current operation, and there is typically a mechanism for providing feedback to the calling program (Escape message, for example.)

Here's the "book" on it:


Here's a sample FTP exit program:


Oh, and you can buy packages or pre-coded
- Gary Patterson

LVL 36

Expert Comment

by:Gary Patterson
ID: 23606196
exit point programs.

(Premature "sumitification")
LVL 36

Assisted Solution

by:Gary Patterson
Gary Patterson earned 1000 total points
ID: 23606311
Tom makes a good point, if you are tying to run a command or program from inside your FTP script (as pooosed to set up a program that gets run by the OS when FTP is utilized), then you can use the RCMD directove.

RCMD is a server-side  FTP directive on the AS/400 that executes the AS/400 command that follows.  In Windows, you use the QUOTE command to tell the Windows FTP client to pass the RCMD directive to the FTP server:


Would tell Windows FTP client to pass


to the FTP server, which would then pass the command


to the operating system for execution.  Run the command tnd then log onto the AS.400 using the same provile and do a WRKSPLF to file the output.

You can, of course, execute other programs or call programs this way, too,  The profile that you sign on under needs to have rights to perform the command requested.  IF there is an FTP exit program registered, it may implement additional restrictions:

QUOTE RCMD CALL PGM(LIB/PGM) PARM('Parameter1' 'Parameter2')

I'm not even going to complete the last one, but it illustrates the reason that you have to be careful with how much command authority that you grant FTP user profiles.  If authorized, they can execute commands that clear libraries, power down the system, and more.  This is one reason that you may want to implement Exit point programs to strictly limit the directives that can be executed using the QIBM_QTMF_CLIENT_REQ exit point.

- Gary Patterson

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows 7 does not have the best desktop search built in. This is something Windows 7 users have struggled with. You type something in, and your search results don’t always match what you are looking for, or it doesn’t actually work at all. There ar…
I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question