LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 01-28-2010, 05:08 AM   #1
mikejosh
LQ Newbie
 
Registered: Jan 2010
Posts: 7

Rep: Reputation: 0
Unhappy 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" >
 
Old 01-28-2010, 05:23 AM   #2
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,727

Rep: Reputation: 452Reputation: 452Reputation: 452Reputation: 452Reputation: 452
'if' statements need a closing 'fi' line -there are two missing in the posted code. Also, the 'while' needs a closing 'done' line.
 
Old 01-29-2010, 06:17 AM   #3
mikejosh
LQ Newbie
 
Registered: Jan 2010
Posts: 7

Original Poster
Rep: Reputation: 0
Thumbs up

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
 
Old 01-29-2010, 06:48 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,523
Blog Entries: 27

Rep: Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174
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.
 
Old 01-29-2010, 06:54 AM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
syntax error near unexpected token `else' alex0 Programming 7 07-28-2009 08:01 AM
sh: syntax error near unexpected token `(' venkatesh_b Linux - Newbie 1 05-16-2009 05:44 AM
Syntax error near unexpected token fi Nortekman Linux - Newbie 8 02-27-2009 03:48 PM
syntax error near unexpected token Aigarzs Linux - Newbie 3 01-12-2008 03:39 PM
syntax error near unexpected token deskjockey39 Linux - General 2 01-16-2007 08:47 AM


All times are GMT -5. The time now is 10:25 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration