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

Posted on 2009-02-10
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
    LVL 26

    Accepted Solution


    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 34

    Expert Comment

    by:Gary Patterson
    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 34

    Expert Comment

    by:Gary Patterson
    exit point programs.

    (Premature "sumitification")
    LVL 34

    Assisted Solution

    by:Gary Patterson
    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

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    #Citrix #POC #XenDesktop #vCenter #VMware #ESX
    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…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    733 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

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now