Search code examples
linuxbashcommandbackendibm-midrange

FTP bash script for iSeries AS400 from linux


I have a bash script in a nodejs back-end application and I need it to execute an Iseries as400 instruction via FTP

#!/usr/bin/bash

host='www.hosting.com'
user='username'
pass='password'

ftp -inv $host << EOF

user $user $pass

QUOTE RCMD CHGUSRPRF USRPRF(USEREXAMPLE) STATUS(*DISABLED)

bye

EOF

The problem is that when executing it, it returns this:

ftp> QUOTE RCMD CHGUSRPRF USRPRF(INT0000279) STATUS(*ENABLED)
**?Invalid command**
ftp>

If i run the script from windows it works, but it fails on linux

Should I install any dependencies on linux for it to run successfully?

I appreciate your help


Solution

  • ftp works for me from a bash command line to the ibm i:

    steve@DESKTOP-MQ27OQB:/mnt/c/Users/srich/downloads/steve$ ftp 172.16.1.254
    Connected to 172.16.1.254.
    220 Connection will close if idle more than 5 minutes.
    Name (172.16.1.254:steve): srichter
    331 Enter password.
    Password:
    230 SRICHTER logged on.
    Remote system type is .
    ftp> quote rcmd sndmsg msg(abc) tousr(*sysopr)
    250 Command sndmsg msg(abc) tousr(*sysopr) successful.
    ftp> quote rcmd chgusrprf usrprf(srichter) status(*enabled)
    550-Error occurred on command chgusrprf usrprf(srichter) status(*enabled).
    550 *SECADM required to create or change user profiles..
    

    Can you run FTP, outside of the bash script, one command at a time?