AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
 View Only
  • 1.  Error in FTP script

    Posted Mon January 07, 2008 03:52 AM

    Originally posted by: SystemAdmin


    Hi, I am trying to use one ftp script which was written in UNIX, in AIX. When I try to execute the script, I am getting an error like the following.

    Unknown option-T.

    ftp -n -i -T 3 $host_name 1>>$Ftperr_Filename 2>&1 << FTPBLOCK1

    This is the command, in which it is throwing the error. If anybody knows, what is the equivalent for the -T option in AIX, please let me know.
    Thanks,
    RAM

    The script is below.

    #!/bin/ksh
    host_name=$1
    usr_name=$2
    pwd=$3
    src_dir=$4
    dest_dir=$5
    echo "ftp begins"
    SOURCE_FILES=$6
    FILE_TYPE=${SOURCE_FILES##*.}

    Ftperr_Filename=myftp.ftp.err

    if $FILE_TYPE == \"list\"
    then
    echo "Retrieving from list"
    #set -x
    for filename in `cat $src_dir/$SOURCE_FILES`
    do
    echo 'FILE NAME INSIDE SHELL' $filename
    echo $filename > $Ftperr_Filename
    ftp -n -i -T 3 $host_name 1>>$Ftperr_Filename 2>&1 << FTPBLOCK
    quote USER $usr_name
    quote PASS $pwd
    verbose
    ascii
    lcd $src_dir
    cd $dest_dir
    put $filename
    close
    FTPBLOCK
    if `grep -ci \"refused\" $Ftperr_Filename` != 0
    then
    Ftp_Status_Msg='FTP SERVER IS DOWN'
    Ftp_Exit_Status=1
    elif `grep -ci 'unknown host' $Ftperr_Filename` != 0
    then
    Ftp_Status_Msg='Unknown Host'
    Ftp_Exit_Status=1
    elif `grep -ci 'command not understood' $Ftperr_Filename` != 0
    then
    Ftp_Status_Msg='command not understood'
    Ftp_Exit_Status=1
    elif `grep -ci 'Login incorrect' $Ftperr_Filename` != 0
    then
    Ftp_Status_Msg='Login incorrect'
    Ftp_Status_Msg='Login incorrect'
    Ftp_Exit_Status=1
    elif `grep -ci 'Cannot create' $Ftperr_Filename` != 0
    then
    Ftp_Status_Msg='Cannot Create File Remote Server'
    Ftp_Exit_Status=1
    elif [ `grep -ci 'No such file or directory' $Ftperr_Filename` != 0
    then
    Ftp_Status_Msg='No such file or directory'
    Ftp_Exit_Status=0
    echo '***Failed To Transfer The File***' $Ftperr_Filename
    echo $Ftp_Status_Msg
    elif `grep -ci 'Connection timeout' $Ftperr_Filename` != 0
    then
    Ftp_Status_Msg='Connection Timeout'
    Ftp_Exit_Status=1
    elif `grep -ci 'Permission denied' $Ftperr_Filename` != 0
    then
    Ftp_Status_Msg='Permission denied'
    Ftp_Exit_Status=1
    else
    Ftp_Exit_Status=0

    fi

    if $Ftp_Exit_Status != \"0\"
    then
    echo '***Failed To Transfer The File***'
    echo $Ftp_Status_Msg
    exit 1
    fi
    cat $Ftperr_Filename
    done

    else
    echo 'Inside else blockkkkkkkkkkkk'
    echo 'FILE NAME : ' $SOURCE_FILES
    echo 'HOST NAME : ' $host_name
    echo 'USER NAME : ' $usr_name
    echo 'PASSWORD : ' $pwd

    echo $filename > $Ftperr_Filename
    ftp -n -i -T 3 $host_name 1>>$Ftperr_Filename 2>&1 << FTPBLOCK1
    #ftp $host_name 1>>$Ftperr_Filename 2>&1 << FTPBLOCK1
    quote USER $usr_name
    quote PASS $pwd
    verbose
    ascii
    lcd $src_dir
    cd $dest_dir
    get $SOURCE_FILES
    close
    FTPBLOCK1
    if `grep -ci \"refused\" $Ftperr_Filename` != 0
    then
    Ftp_Status_Msg='FTP SERVER IS DOWN'
    Ftp_Exit_Status=1
    elif `grep -ci 'unknown host' $Ftperr_Filename` != 0
    then
    Ftp_Status_Msg='Unknown Host'
    Ftp_Exit_Status=1
    elif `grep -ci 'command not understood' $Ftperr_Filename` != 0
    then
    Ftp_Status_Msg='command not understood'
    Ftp_Exit_Status=1
    elif `grep -ci 'Login incorrect' $Ftperr_Filename` != 0
    then
    Ftp_Status_Msg='Login incorrect'
    Ftp_Exit_Status=1
    elif `grep -ci 'Cannot create' $Ftperr_Filename` != 0
    then
    Ftp_Status_Msg='Cannot Create File Remote Server'
    Ftp_Exit_Status=1
    elif [ `grep -ci 'No such file or directory' $Ftperr_Filename` != 0
    then
    Ftp_Status_Msg='No such file or directory'
    Ftp_Exit_Status=1
    elif `grep -ci 'Connection timeout' $Ftperr_Filename` != 0
    then
    Ftp_Status_Msg='Connection Timeout'
    Ftp_Exit_Status=1
    elif `grep -ci 'Permission denied' $Ftperr_Filename` != 0
    then
    Ftp_Status_Msg='Permission denied'
    Ftp_Exit_Status=1
    else
    Ftp_Exit_Status=0
    fi

    if $Ftp_Exit_Status != \"0\"
    then
    echo '***Failed To Transfer The File***'
    echo $Ftp_Status_Msg
    exit 1
    fi
    cat $Ftperr_Filename

    fi
    exit 0
    #AIX-Forum