mercredi 20 septembre 2017

unix if condition error

I have a unix shell script that reads parameter from command line and then exit in case parameter missing. Then i tested with parameter, which is supposed to work fine but it exit with error. anyone can check please?

SCRIPT:

#!/bin/ksh
##########################################################################
#       Remote to upstream servers to check feed files without password  #
#               ELLA YE                                                  #
#               Sept 20 2017                                             #
#               Version 1                                                #
##########################################################################

RUNDIR=/tmp
UPSTREAM_USER="$1"
UPSTREAM_SERVER=$2
UPSTREAM_DIR=$3
FILE_NAME=$4
LOCAL_DIR=$5

echo $5
#if [[ ( "$1" = "" ) || ( "$2 = "" ) || ( "$3" = "" ) || ( "$4" = "" ) || ( "$5 = "" ) ]]
if [ $5 -eq "" ];
then
        echo "Parameter missing"
exit 1;
fi

my command:

./sftpupstream.ksh abc abc.wlb2.nam.nsroot.net . .profile .

result:

.

Parameter missing

bash-4.1$

Aucun commentaire:

Enregistrer un commentaire