Reputation: 33
i need help in bash script I have a lic.txt at domain.com which contains the string "1234567". i want to use string "1234567". in bash script if this word found in http://domain.com/license.txt run bash script function if not found output error license invalid how can i add this in my bash script
my bash script code is
if [ $1 ]; then
SIZE=$(($1 * 1024))
else
SIZE=$((100 * 1024))
fi
Sname=`echo $0 | sed 's/.\///g'`;
for x in $TXT_PATH/*_t.txt
do
if [ ! -e $LOCK_FILE ]; then
if [ "$x" == "$Sname" ]; then
echo -ne;
elif [ -d "$x" ] || [ -e "$x" ]; then
/bin/touch $LOCK_FILE
My command 1
My command 2
My command 3
My command 4
My command 5
My command 6
My command 7
rm -rf $LOCK_FILE
fi
else
echo "Lock file remove for run"
fi
done
Upvotes: 0
Views: 433
Reputation: 5586
If I understand the question correctly you need something like that:
wget http://domain.com/license.txt
code = $(grep 1234567 license.txt)
if [ -z $code ]; then echo "Invalid license"; else function_call_here; fi
Thanks Fredrik
Upvotes: 2