-1

I find that ssh used like ssh "cmd" but can`t realise it in script when i need to run it from one machine where pattern of file if created to another when file are generated.

#!/bin/bash
VENUE=TE
Date=$(date +%Y%m%d)
SCRIPT_PATH=$PWD
TRC_PATH=$DSS_TRC
PATTERN_PATH=${SCRIPT_PATH}/Patterns

COUNTER=0
echo "$(tput setaf 5)Test 10. GTPTE instance check$(tput sgr0)"
echo "Checking GTP${VENUE} instance"

while read PATTERN
do
        INSTANCE=GTP${VENUE}
        if [ ssh host@name "cat ${TRC_PATH}/${INSTANCE}*_${Date}*.trc |  grep "$PATTERN" | wc -l"  -ge 1 ]
                then
                ((COUNTER=${COUNTER}+1))

                else
                        echo "Test 1 : $(tput setaf 1)[FAILED]$(tput sgr0). Pattern : $PATTERN not found"
                        exit 0
        fi
done < ${SCRIPT_PATH}/Patterns/10_TEST.ptrn
echo "Test 10 : $(tput setaf 2)[PASSED]$(tput sgr0). Number of patterns checked : ${COUNTER}"

Error: [: too many arguments.

Ivan
  • 15
  • 3

1 Answers1

0

First of all, in such cases, try to peek what is the value returned by your ssh command. So assign the result of ssh to a variable and echo it in doubt, or watch with bash -x.

In this case your variable will be "ssh host@name..."

You need to execute the command and get its result. To do this, enclose the whole command in $(yourcommand yourparameters). Then you will find out that you need to fix another thing - it is actually name@host.

After all this it should work or at list bring you further.