Hi,
I am getting error message while uploading file to Vendor's FTP server as below, I have written Unix script to upload the file on Vendor's FTP server.
Connected to TEST.HOST.COM.
220 Server ready.
331 Password required for FTPUSER.
230 User FTPUSER logged in.
mput file4062.TXT? 200 PORT command successful.
421 Idle Timeout (180 seconds): closing control connection.
FTP return code is:0
SCRIPT_ftp.ksh:TRANSFER ftp ran OK
logout
Please can you let me know is there any settings i have to do in FTP Unix Script for above error? Or there is some problem on Vendor's FTP server. But some time it works perfectly.
Thanks,
Narendra
Solved! Go to Solution.
The idle timeout occurrs because the FTP daemon does not detect any activity on the channel. For some reason, the transfer did not work and no data passed between the systems, resulting in the timeout.
Hi Steven,
Please find the FTP script as below, And OS is (HP-UX server1 B.11.31 U ia64 0716105793 unlimited-user license)
#!/bin/ksh
cd /SID/outgoing
filecount=`ls | wc -l`
if test $filecount = 0
then
echo ""
echo "XXXXXXXXXXXXXXXXXXXXXXXXX"
echo "THERE ARE NO FILES TO SEND"
echo "XXXXXXXXXXXXXXXXXXXXXXXXX"
echo ""
#exit
fi
file=$(ls)
for x in $file
do
mv $x $x.TXT
chmod 444 $x.TXT
done
HOST='TEST.HOST.COM'
USER='FTPUSER'
PASSWD='password'
ftp -nv $HOST <<EOF
user $USER $PASSWD
mput *.TXT
EOF
RC=$?
echo "FTP return code is:$RC"
if test RC -ne 0
then
echo "Outgoing_ftp.ksh:Error running ftp for Outgoing"
else
echo "Outgoing_ftp.ksh:Outgoing ftp ran OK"
fi
echo ""
Datestamp=$(date +%Y%m%d%H%M)
file=$(ls)
for x in $file
do
mv $x ../old/$x.$Datestamp
done
And what i mean with some time it works perfectly... Is i won;t get error "421 Idle Timeout (180 seconds)" while file transfer...But some time i get an error Timeout.
Thanks,
Narendra
>if test $filecount = 0
You should clean this up to use -eq:
if [ $(ls | wc -l) -eq 0 ]; then
>ftp -nv $HOST <<EOF
Based on Steven's comments, this will prompt for each file, even if 1. So you need:
ftp -niv $HOST <<EOF
>if test RC -ne 0
This should be:
if [ $RC -ne 0 ]; then
>file=$(ls)
>for x in $file; do
Any reason you don't use the previous list? Someone may put another file there and you wouldn't copy it.
for x in $file; do
mv $x.TXT ../old/$x.$Datestamp
done
>perhaps the FTP client doesn't ask about an "mget" or "mput" if the file list ("*.TXT") expands to only one file.
It asked for me.
>Which is why "prompt" is normally used
Or -i.
>(Apparently, your file names don't include spaces.)
That would be illegal, wouldn't it? ;-) It seems it is pushing from HP-UX to Windows.
And to fix this, you would also have to change the for loop to something like:
for x in "$(ls)"; do