Execute remote commands using FTP

Learn how to use FTP to enter commands on a remote systems.

Many of you use FTP to transfer files between systems, and FTP is an excellent tool for that purpose. Did you also know that by using FTP, you can enter commands on remote systems? You can do this with the quote command. The quote command lets you send arbitrary commands to the FTP server. By using server sub-commands in conjunction with the quote command, you can execute most AS/400 commands from within your FTP session. Using this...

approach, you can create files, restore objects, etc. as part of your FTP job stream. The AS/400 sub-command that allows you to do this is rcmd, which allows you to execute remote commands through your FTP server.

Example: quote rcmd CLRPFM FILE(MYLIB/MYFILE) -- Will clear the specified file on the remote system

If you are in an FTP session and want to enter a command on the LOCAL system, you can use the ! command. This works a little differently on the AS/400 and in Windows.

If you enter ! from the a Windows DOS prompt FTP session, you temporarily exit to the DOS prompt until you decide to resume your FTP session. If you enter ! from an AS/400 FTP session, the AS/400 expects you to follow it with an AS/400 command.

Example: ! sndmsg msg(Hello) tousr(tim)

Although not related to the topic at hand, here is another server sub-command I find very useful:

By default, your FTP session will time out after five minutes of inactivity. Using the time command you can increase that amount of time to whatever you choose.

Example: quote time 10000 -- Sets the FTP inactivity timeout to 10,000 seconds

This was first published in March 2001



Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: