Argument expected error from test

Argument expected error from test

Post by greyf.. » Sun, 23 Nov 2003 06:50:50



I don't see what I'm doing wrong here. Any idea why this would return
an "Argument expected" error from test. If I pass two or more
variables, it works. If I only pass one, it gives the error. It looks
to me as if it should work with one variable, so long as that variable
is not "-bk" or "-BK". I'll build in some error checking to work
around that, but for now I'm perplexed.

if [ "$1" = "-bk" -o "$1" = "-BK" ]
then
  BACKUP=1
  shift
fi


do
  if [ $BACKUP -eq 1 ]
  then
    copy -ovrm $i $i.bak >/dev/null
  fi
  RXFILE $i $i
  case $i in
    SS*) dtox $i >$i.$$
         mv $i.$$ $i
         chmod 777 $i ;;
    *)   ;;
  esac
done

 
 
 

Argument expected error from test

Post by Barry Margoli » Sun, 23 Nov 2003 07:12:05




>I don't see what I'm doing wrong here. Any idea why this would return
>an "Argument expected" error from test. If I pass two or more
>variables, it works. If I only pass one, it gives the error. It looks
>to me as if it should work with one variable, so long as that variable
>is not "-bk" or "-BK". I'll build in some error checking to work
>around that, but for now I'm perplexed.

If the first argument isn't -bk or -BK, you never set $BACKUP to anything.
As a result, the later "if" statement expands to:

if [ -eq 1 ]

which is missing an argument.  Change that line to:

if [ "$BACKUP" = 1 ]

>if [ "$1" = "-bk" -o "$1" = "-BK" ]
>then
>  BACKUP=1
>  shift
>fi


>do
>  if [ $BACKUP -eq 1 ]
>  then
>    copy -ovrm $i $i.bak >/dev/null
>  fi
>  RXFILE $i $i
>  case $i in
>    SS*) dtox $i >$i.$$
>         mv $i.$$ $i
>         chmod 777 $i ;;
>    *)   ;;
>  esac
>done

--

Level(3), Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 
 
 

Argument expected error from test

Post by Stephane CHAZELA » Sun, 23 Nov 2003 07:49:29



[...]

Quote:> if [ "$1" = "-bk" -o "$1" = "-BK" ]

if [ "x$1" = x-bk ] || [ "x$1" = x-BK ]

[...]

for i

or


Quote:> do
>   if [ $BACKUP -eq 1 ]

if [ "$BACKUP" -eq 1 ]

Quote:>   then
>     copy -ovrm $i $i.bak >/dev/null

     copy -ovrm "$i" "$i.bak" >/dev/null

Quote:>   fi
>   RXFILE $i $i

    RXFILE "$i" "$i"

Quote:>   case $i in
>     SS*) dtox $i >$i.$$
>     SS*) dtox $i >$i.$$
>          mv $i.$$ $i
>          chmod 777 $i ;;

    SS*) dtox "$i" > "$i.$$"
    SS*) dtox "$i" > "$i.$$"
         mv -- "$i.$$" "$i"
         chmod 777 -- "$i" ;;

Quote:>     *)   ;;
>   esac
> done

--
Stphane                      ["Stephane.Chazelas" at "free.fr"]
 
 
 

1. Help me with this error message : test: argument expected

Here is the script I am trying to write

#!/usr/bin/sh

ORACLE_HOME=/opt/oracle8/product/8.1.7
JAVA_HOME=/usr/java1.2
JAVA_LIBS=/home/kpatil/myclasses/smtp.jar:/home/kpatil/myclasses/activation.jar:$ORACLE_HOME/jdbc
/lib/classes12.zip
SCRIPT_DIR=/home/kpatil/visteon
FLUSH_DIR=$SCRIPT_DIR/dbload/flushes

echo $1 | grep -i "830" > /dev/null
if [ $? -eq 0 ]
then
  echo Visteon DB Load Files
  PROCESS_FILE=`echo $1 | awk -F/ '{ print $NF }'`
  echo "Trying to process file $PROCESS_FILE";
  if [ -e "$FLUSH_DIR/${PROCESS_FILE}.flushes" ]
  then
        echo "File with same name has been processed" | mail

  else
  cd $SCRIPT_DIR/dbload;
  $JAVA_HOME/bin/java -classpath $JAVA_LIBS:$SCRIPT_DIR/dbload
VisteonDBLoad -f $1 2>&1 | mail kp

  if [ -e "$1.flushes" ]
   then
        mv $1.flushes $SCRIPT_DIR/dbload/flushes
  fi
  fi
fi

-- END

I guess it is failing on  'if [ -e
"$FLUSH_DIR/${PROCESS_FILE}.flushes" ]' with error test: argument
expected. What am I doing wrong here?

Thanks,
Kunal Patil

2. Sound under Slackware 3.6

3. test: argument expected error

4. how big would your box be ....

5. test test test test test test test

6. Looking for example UDP file transfer code (both client and server) in C

7. how to pass this argument to Expect ?

8. SSH SHELL SETUP

9. syntax error: operand expected (error token is " ")

10. test test test test

11. error: Linux Error: 22: Invalid argument

12. Odd Xconfig Errors: syntax error, non-numeric arguments...?

13. SIGCHLD doesn't work right in Linux (using Expect to test)