FTP failure with different scenario

Hi Gurus

the below FTP code works fine, but the issue is from past 1 week couldn't able to send the files to external system.

#--------------------------------------------------------------------#
#Start the ftp session
#--------------------------------------------------------------------#
#!/bin/sh
ftp -inv host_name << -END- > log_name
close
-END-

if cat log_name | grep -Ei 'not timed out refused' > /dev/null
then
   cat log_name
   rm -f log_name
   exit 1
   echo 'FTP connection failed'
else
	ftp -inv host_name << -END-   > log_name
	user user_name password
	cd $RFOLDER
	put $FOLDER/$FILE.sql.Z $FILE.sql.Z
	quit
	-END-

	if cat log_name|  grep -v bytes | awk '{print $1}' | grep -Ei '530
        425  426 450 451 452 500 501 503 504 530 532 550 551 552 553	421 ' > /dev/null
	then
	  cat log_name
	  rm -f log_name
	  exit 1
	  echo 'FTP failed'
	else
	  cat log_name
	  rm -f log_name
	  exit 0
	  echo 'FTP was successful'
	fi
fi

exit 0;

issue is :-

username was decommissioned and updated the new username but one of our support team accidently updated the old one.

my question is why the FTP code didn't raise the failed FTPed error and what will be the scenrios .

Please provide the solution for this

Thanks in Advance

---------- Post updated at 02:51 PM ---------- Previous update was at 11:14 AM ----------

any help in this....

error log from autosys says

ftp: Name or service not known
ftp: Name or service not known

error log from script says
Not Connected

do we have any code's for the above error.

please share the information

Automated FTP scripts usually rely on the remote machines account credentials being available in the file .netrc in the home directory of the user under which the command is running. Google for ".netrc"

If the ftp is failing perhaps .netrc does not have the correct credentials for ftp automation.

As for why the script didn't detect the ftp failure I'm not sure.

Thanks hicksd8,they have updated the username and seems that working fine.

there are asking why it didn't trap the error.

do we have anything to get ride of the error(unexpected errors) or any code changes will be helpful.Please share the information

First impression is that the egrep (or grep -E ) commands don't work because the "|" (the "or" operator) is totally missing.

echo "hello" | egrep "hello banana sausage"

<no answer>

echo "hello" | egrep "hello|banana|sausage"
hello

After another look. Hmm. What Shell is this? The script contains many errors. Please post what you want the script to achieve.