LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Syntax error near unexpected token :( please help (https://www.linuxquestions.org/questions/programming-9/syntax-error-near-unexpected-token-please-help-785304/)

mikejosh 01-28-2010 05:08 AM

Syntax error near unexpected token :( please help
 
i got this script from website for inviting peoples to game and earning points easily ...but this seems not working and giving error..any help in correcting it and sharing knowledge is much appreciated

#!/bin/bash/sh
#Store arguments from bash command line
username=$1
cycles=$2
i=$1
if [ -z ${username} ] || [ ! -e ./cookies/${username} ]
then
echo "Error: Login to your E-Mail Account"
echo
exit
if [ +z ${username}] || [!-e./cookies/${username} ]
then
echo "successfull"
echo
exit
if [ -z ${cycles} ]
then
echo "Default Cycle to 1"
cycles=1
fi

while [ $i -le ${cycles} ]
do
echo "Running cycle ${i}"
curl -s -b ./cookies/$username -A "Mozilla/5.0" -d @./data/acashdat "http://apps.facebook.com/fightersc/recruiter?from=money&sent=1" >

gnashley 01-28-2010 05:23 AM

'if' statements need a closing 'fi' line -there are two missing in the posted code. Also, the 'while' needs a closing 'done' line.

mikejosh 01-29-2010 06:17 AM

thanks alot buddy :) it worked in that script but couldnt get it right in this one..its similar to first but for differect activity

#!/bin/bash

fid=$1
email=$2

if [ -z ${email} ] || [ ! -e ./cookies/${email} ]
then
echo "You need to specify a logged in email address"
echo "that person must be already supporting the fight"
echo
exit
fi

while [ 1 ]
do
curl -s -b ./cookies/$email -A "Mozilla/5.0" "http://apps.facebook.com/fightersc/details?fid=${fid}&hit=1" | sed -n "s/.*opponent\" value=\"\([0-9]*\)\" .*/\1/p" | while read i; do
echo "Got one! beating the shit out of ${i}"
curl -s -I -b ./cookies/$email -A "Mozilla/5.0" "http://apps.facebook.com/fightersc/details?fid=${fid}&hit=1&emoticon=119&opponent=${i}&versailles=hit+opponent" > /dev/null&
curl -s -I -b ./cookies/$email -A "Mozilla/5.0" "http://apps.facebook.com/fightersc/details?fid=${fid}&hit=1&emoticon=119&opponent=${i}&versailles=hit+opponent" > /dev/null&
done
done

catkin 01-29-2010 06:48 AM

It's easier to read your script if you put it in code tags (that's a link to instructions or you may prefer to use "Advanced Edit" mode which has a # button for code tags). This will preserve the indentation you are (hopefully) using.

Please post the output too. It should show information about the line number(s) generating the error.

pixellany 01-29-2010 06:54 AM

Where are you getting these scripts?

Regardless, please put code like this into code tags (switch to advanced mode if necessary)

In your latest script, I am not sure what happens when you pipe data into the "while read i......" construct. "read" takes data from standard input, unless told otherwise.

Example: To read from a file:
Code:

while read line; do
    echo $line
done < filename

More generally, the first thing to do when debugging is to try each piece in a terminal to make sure it's doing the right thing.


All times are GMT -5. The time now is 11:12 PM.