Printable Version of Topic

Click here to view this topic in its original format

Linuxhelp _ Programming in Linux _ script syntax help

Posted by: horridon Feb 2 2015, 07:56 AM

CODE
#!/bin/bash
if [ -z "$1" ]; then
echo "Lipsa IP";
exit;
fi
i=1
ip=$1
while [ $i -le `wc -l pass_file | awk '{print $1}'` ]; do
if [ -n "$ip" ]; then
rand=`head -$i pass_file | tail -1`
user=`echo $rand | awk '{print $1}'`
pass=`echo $rand | awk '{print $2}'`

CMD=`ps -eaf | grep -c mysql`

if [ "$CMD" -lt "50" ]; then
./mysql $ip $user $pass &
else
        sleep 15
fi
    i=`expr $i + 1`

done


Output is:

CODE
./sql2: line 23: syntax error near unexpected token `done'
./sql2: line 23: `done'


Can someone fix this and paste the corrected version?

Posted by: michaelk Feb 2 2015, 02:29 PM

We will help you debug your program but will not do the work for you and I hope others do the same. Besides you have not said anything about what this program does or the format / contents of the pass_file

Looks like your missing a fi for this if statement
if [ -n "$ip" ]; then

Posted by: EnricTellez Dec 9 2016, 06:27 AM

Thanks for the help <a href="http://enrictellez.nl">Enric Tellez</a>

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)