Link to home
Start Free TrialLog in
Avatar of sunhux
sunhux

asked on

Linux Shell ftp put script to HP-Ux ftp server fails when ftp to replacement Solaris ftp server

I have an ftp script which used to put text files over to
HP-Ux B11.11 ftp server.

A couple of days back, we replaced this HP-Ux with a Solaris
10 ftp server.  The Solaris server has a different IP addr
& we're supposed to decommission the HP-Ux server.

The only change to this Linux (Redhat 4.6 RHES) ksh script
is the IP addr of the remote ftp server.  Both the HP-Ux
& Solaris are on the same LAN as the Linux (just that the
Linux is in a different subnet).


If I manually ftp at command prompt from this Linux ftp
client to the Solaris server using the very same login id
& password (as the Shell script), it could login Ok, cd to
the destination directory & put a file successfully.

I suspected 3 lines are the possible culprits (indicated by ## below).

But if this script is run from Solaris cron it would fail with
incorrect login / password (see below for actual error messages).

If this script is run interactively on the Linux command line,
it was Ok but after running interactively a few times, it
doesn't allow me to login anymore.


any idea?

=========== Stdout & stderr outputs =============

GSSAPI error major: An invalid name was supplied
GSSAPI error minor: Cannot determine realm for numeric host address
GSSAPI error: parsing name
name parsed <ftp@172.16.25.58>

GSSAPI error major: An invalid name was supplied
GSSAPI error minor: Cannot determine realm for numeric host address
GSSAPI error: parsing name
name parsed <host@172.16.25.58>

GSSAPI authentication failed
KERBEROS_V4 rejected as an authentication type
Password:
ftp: bind: Address already in use
Login incorrect.
Login failed.
Passive mode refused.  Turning off passive mode.
GSSAPI error major: An invalid name was supplied
GSSAPI error minor: Cannot determine realm for numeric host address
GSSAPI error: parsing name
name parsed <ftp@172.16.25.58>

GSSAPI error major: An invalid name was supplied
GSSAPI error minor: Cannot determine realm for numeric host address
GSSAPI error: parsing name
name parsed <host@172.16.25.58>

======== Linux ftp script codes ==================

#!/usr/bin/ksh


JOB_DIR=$2
JOB_NAME=$3
FILE_LIST=$4
LOCAL_DIR=$5
REMOTE_DIR=$6

LOG_DIR=$JOB_DIR/log
ENV_SETTING="$JOB_DIR/cron_env.dat"


ERR_NAME=$JOB_NAME.err
LOG_NAME=$JOB_NAME.log
TMP_LOG_NAME=tmp_$JOB_NAME.log


IP=`grep Remote_IP $ENV_SETTING | cut -f2 -d =`
echo $IP >> /tmp/getmed.ip
FTP=`grep Remote_Login_id $ENV_SETTING | cut -f2 -d =`
echo $FTP >> /tmp/getmed.FTP
PASS=`grep Remote_Password $ENV_SETTING | cut -f2 -d =`
echo $PASS >> /tmp/getmed.PASS


for FILE_NAME in $FILE_LIST
do
if [ -r $LOCAL_DIR/$FILE_NAME ]
then
        if [ $1 == "append" ]
        then
                cat $LOCAL_DIR/$FILE_NAME >> $LOCAL_DIR/$FILE_NAME.append
                cp $LOCAL_DIR/$FILE_NAME.append $LOCAL_DIR/$FILE_NAME
        fi
fi
done

        ## echo "user $FTP"
        ## echo "\c"

        ## echo user
        ## echo "$FTP \c"


echo "--------------- Start Connecting to Remote Server at " `date` " ---------------">> $LOG_DIR/$LOG_NAME

       DATERUN=`date '+%Y%m%d%H%M'`
       {
        echo "open $IP"
        echo user              ## is this line the culprit or
        echo "$FTP \c"       ## this line or
        echo "$PASS"
        echo "verbose"
        echo "prompt off"
        echo "lcd $LOCAL_DIR"
        echo "cd $REMOTE_DIR"

        for FILE_NAME in $FILE_LIST
        do
        if [ -r $LOCAL_DIR/$FILE_NAME ]
        then
                        a1="tar"
                        a2=`echo $FILE_NAME | cut -f2 -d .`
                        if [ $a2 == $a1 ]
                        then
                                echo binary
                        else
                                echo binary
                        fi
                        echo "ren $FILE_NAME $FILE_NAME.bak"
                        echo "put $FILE_NAME"
                fi
        done

        echo bye

        } | ftp -n 2>&1 > $LOG_DIR/$TMP_LOG_NAME   ## this line??

        cat $LOG_DIR/$TMP_LOG_NAME >> $LOG_DIR/$LOG_NAME

        egrep "fail|refused|Not|error|incorrect|denied|unknown|timed out" $LOG_DIR/$TMP_LOG_NAME

        if [ "$?" -eq 0 ]; then
         sleep 3
      echo "--------------- Re-try to connect to Remote Svr ...,, at " `date` " ---------------" >> $LOG_DIR/$LOG_
NAME
         {
                echo "open $IP"
                echo user
                echo "$FTP \c"
                echo "$PASS"
                echo verbose
                echo "prompt off"
                #echo passive
                echo "lcd $LOCAL_DIR"
                echo "cd $REMOTE_DIR"

                for FILE_NAME in $FILE_LIST
                do
                if [ -r $LOCAL_DIR/$FILE_NAME ]
                then
                                a1="tar"
                                a2=`echo $FILE_NAME | cut -f2 -d .`
                                if [ $a2 == $a1 ]
                                then
                                        echo binary
                                else
                                        echo binary
                                fi
                                echo "ren $FILE_NAME $FILE_NAME.bak"
                                echo "put $FILE_NAME"
                        fi
                done

                echo bye
         } | ftp -n 2>&1 > $LOG_DIR/$TMP_LOG_NAME
         cat $LOG_DIR/$TMP_LOG_NAME >> $LOG_DIR/$LOG_NAME
        fi

       egrep "fail|refused|Not|error|incorrect|denied|unknown|timed out" $LOG_DIR/$TMP_LOG_NAME

        if [ "$?" -eq 0 ]; then
                #echo `date` "-----------$FILE_NAME :: Can't connect to Remote Svr: Connection refused, files are
kept at FTP Server"  >> $LOG_DIR/$ERR_NAME
                echo `date +%d_%B_%Y_%T` "-----------$FILE_NAME :: Can't connect to WEBLOGIC: Connection refused
, files are kept at FTP Server"  >> $LOG_DIR/$ERR_NAME
        else
                for FILE_NAME in $FILE_LIST
                do
                        if [ -r $LOCAL_DIR/$FILE_NAME ]
                        then
                            mv  $LOCAL_DIR/$FILE_NAME   $LOCAL_DIR/$FILE_NAME.$DATERUN
                            mv  $LOCAL_DIR/$FILE_NAME.md5   $LOCAL_DIR/$FILE_NAME.md5.$DATERUN
                        fi
                done
        fi

echo "--------------- End Connecting to Remote Server at " `date` " ---------------">> $LOG_DIR/$LOG_NAME

rm  $LOG_DIR/$TMP_LOG_NAME
SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sunhux
sunhux

ASKER

No joy
Avatar of sunhux

ASKER

Still getting the same invalid login messages
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sunhux

ASKER

>didn't add the new machine to the Kerberos realm.
On the Solaris end, "svcs -a | grep krb" showed Kerberos is
disabled.  Also, ftp at command prompt works.

ksh -v scriptname   or   sh -v scriptname
with  > file1.txt   and   2> file2.txt   gave
nothing in file2.txt but the following in file1.txt:
(as given in my first post above):

If I manually ftp at command prompt from this Linux ftp
client to the Solaris server using the very same login id
& password (as the Shell script), it could login Ok, cd to
the destination directory & put a file successfully.




=========== Stdout & stderr outputs =============

GSSAPI error major: An invalid name was supplied
GSSAPI error minor: Cannot determine realm for numeric host address
GSSAPI error: parsing name
name parsed <ftp@172.16.25.58>

GSSAPI error major: An invalid name was supplied
GSSAPI error minor: Cannot determine realm for numeric host address
GSSAPI error: parsing name
name parsed <host@172.16.25.58>

GSSAPI authentication failed
KERBEROS_V4 rejected as an authentication type
Password:
ftp: bind: Address already in use
Login incorrect.
Login failed.
Passive mode refused.  Turning off passive mode.
GSSAPI error major: An invalid name was supplied
GSSAPI error minor: Cannot determine realm for numeric host address
GSSAPI error: parsing name
name parsed <ftp@172.16.25.58>

GSSAPI error major: An invalid name was supplied
GSSAPI error minor: Cannot determine realm for numeric host address
GSSAPI error: parsing name
name parsed <host@172.16.25.58>
Did you read my #38316458 above?
Avatar of sunhux

ASKER

The following works:

.....  open $IP .....
echo "quote USER $USER"
echo "quote PASS $PASS"
did you read my comment ID: 38316640
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sunhux

ASKER

Yes, I saw both your comments

but the following probably has typo error as we can't echo username
& password on the same line, syntax not supported:
 > echo "$FTP $PASS"

while,
I've indicated that the backend/remote servers were migrated
from HP-Ux to Solaris, no other changes.  I've also done "ksh -v"
but it only points to the fact that there's invalid login id/password:

 > Have you done any changes on the system recently?
 > Can you run the script with logging and see which step causes
 > the error? you can run it with "ksh -v scriptname"

Or do you mean "ksh -x"  (I always thought it's -v )
Avatar of sunhux

ASKER

Even if I remove "\c" in the original scripts, it doesn't work too.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sunhux

ASKER

No problem with the typo.

Both of you have helped me a lot in EE.
Closing this thread as my 'enormous' problem
is now resolved.

The fact that both of you responded promptly in itself
is a morale support to me.  Certain management at
my place can be very demoralizing