Macro definition missing null line terminator

Hello All ~ can someone please help me. I'm trying to FTP to a server using the macdef init. All was working before our upgrade to red hat 5. Now my FTP process is falling with error given below.

Connected to 10.9.120.1 (10.9.120.1).
220-FTPD1 IBM FTP CS V1R10 at xyz.gx.yz.xyz, 17:30:39 on 2011-04-08.
220 Connection will not timeout.
Macro definition missing null line terminator.
Remote system type is MVS.
ftp>
ftp>
ftp> quit
221 Quit command received. Goodbye.

Here is my script
for USER_TO_FTP in $(echo ${USERS_FTP})
do
        echo "machine ${USER_TO_FTP} login junka password junk1 "> ${HOME}/.netrc
        echo "macdef init"                  >> ${HOME}/.netrc
        echo "prompt off"                   >> ${HOME}/.netrc
        echo "       "                      >> ${HOME}/.netrc
        echo "ascii"                        >> ${HOME}/.netrc
        echo "lcd /home/prodinst/jobs"      >> ${HOME}/.netrc
        echo "cd DB2CON.SYSREC01"                   >> ${HOME}/.netrc
        echo "put DSNP$filedate.txt PROD$filedate"    >> ${HOME}/.netrc
        echo "close"                        >> ${HOME}/.netrc
        echo "quit\n\n"                     >> ${HOME}/.netrc
        chmod 600 $HOME/.netrc




browx24Asked:
Who is Participating?
 
wesly_chenCommented:
1. Your script have "for" loop, where is "done"?

2.
----
        echo "machine ${USER_TO_FTP} login junka password junk1 "> ${HOME}/.netrc
        echo "macdef init"                  >> ${HOME}/.netrc
        echo "prompt off"                   >> ${HOME}/.netrc
        echo "       "                      >> ${HOME}/.netrc     ===>
change to
echo "" >> ${HOME}/.netrc
or delete this line.

3,
    echo "quit\n\n"                     >> ${HOME}/.netrc
change to
echo " quit" >> ${HOME}/.netrc
echo " " >> $HOME/.netrc
# always end a macdef with a blank line
0
 
browx24Author Commented:
Hello Mr Chen ~ Thanks for helping. Your solution worked like a charm. Thanks. See complete soln below:

for USER_TO_FTP in $(echo ${USERS_FTP})
do
        echo "machine ${USER_TO_FTP} login xyz password passxyz "> ${HOME}/.netrc
        echo "macdef init"                  >> ${HOME}/.netrc
        echo "prompt off"                   >> ${HOME}/.netrc
        echo "ascii"                        >> ${HOME}/.netrc
        echo "lcd /home/prodinst/jobs"      >> ${HOME}/.netrc
        echo "cd DB2CON.SYSREC01"                     >> ${HOME}/.netrc
        echo "put DSNP$filedate.txt PROD$filedate"    >> ${HOME}/.netrc
        echo "close"                        >> ${HOME}/.netrc
        echo "quit"                         >> ${HOME}/.netrc
        echo ""                             >> $HOME/.netrc
        chmod 600 $HOME/.netrc

# Ping user to ensure communication.
# Invoke ftp for automated logon and transfers.
#---------------------------------------------------------------------
    ping  -q -c1 ${USER_TO_FTP} 1>/dev/null 2>/dev/null
    RSLT=${?}
    echo "$tdateis Ping returns:$RSLT  " \
             | tee -a /home/prodinst/logs/db2con$filedate.log
   if [ ${RSLT} = 0 ]
    then
      tdateis=`date "+%m%d%y %T"`
      echo "$tdateis Ping was good -- now prepare for FTP process " \
             | tee -a /home/prodinst/logs/db2con$filedate.log

      echo "$tdateis Control is now being given to FTP ...please be patient" \
             | tee -a /home/prodinst/logs/db2con$filedate.log

    /usr/bin/ftp ${USER_TO_FTP} >> /home/prodinst/logs/db2con$filedate.log
      echo "$tdateis FTP process complete successfully " \
             | tee -a /home/prodinst/logs/db2con$filedate.log
    else
       echo "$tdateis !!Ping was BAD* TESTING FAILED!! -- FTP did not run " \
             | tee -a /home/prodinst/logs/db2con$filedate.log

       echo "$tdateis Mainframe can't be reached please investigate " \
             | tee -a /home/prodinst/logs/db2con$filedate.log

    fi
done


 
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.