LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 09-15-2008, 01:42 PM   #1
andremun
LQ Newbie
 
Registered: Sep 2008
Posts: 2

Rep: Reputation: 0
Unhappy Unable to run script. Unexpected token.


Greetings,
I have to run an script that repeats a set of operations, for this reason, I created a script function, but I´m getting the following error message:

Code:
[munoz@comet2 ~/test]$ sh -x tst_script
'st_script: line 5: syntax error near unexpected token `
'st_script: line 5: `invscatexperiment()
The script is as follows:

Code:
#!/bin/sh 
# Script que realiza una prueba completa del algoritmo final
# Prueba los elementos que se conocen trabajan correctamente sin
# mutaciones y aquellos que requieren mutaciones
invscatexperiment() {
	cp $1 geoinp.txt
	for (( n = 1; n <= 20; n++ )); do
		/opt/mpich-ch_p4-gcc-1.2.7/bin/mpirun -np 60 -nolocal -machinefile mlist ~/a1.out
		cp bestChromo.m best_$2_pso_$n.m
		cp evMov.m  move_$2_pso_$n.m
		cp stat.txt stat_$2_pso_$n.txt
		cp scat.txt scat_$2_pso_$n.txt
		~/kill_script

		/opt/mpich-ch_p4-gcc-1.2.7/bin/mpirun -np 60 -nolocal -machinefile mlist ~/a2.out
		cp bestChromo.m best_$2_bpso_$n.m
		cp evMov.m  move_$2_bpso_$n.m
		cp stat.txt stat_$2_bpso_$n.txt
		cp scat.txt scat_$2_bpso_$n.txt
		~/kill_script
	done
	return
}

cp gainvscat1.txt gainvscat.txt
invscatexperiment geoinpRECTdiel.txt RECT    
invscatexperiment geoinpGARBAGE.txt GARBAGE
invscatexperiment geoinpBT.txt BT
invscatexperiment geoinpCONVRECT.txt CONVRECT
invscatexperiment geoinpPACMAN.txt PACMAN

cp gainvscat2.txt gainvscat.txt
invscatexperiment geoinpCIRC.txt CIRC
invscatexperiment geoinpL.txt L
invscatexperiment geoinp2SQ.txt 2SQ
I´m using a Linux machine to run the script, but I have to remote access it. I use a Win machine to edit the code, so this script was made in wordpad :S.
I appreciate any help that you could provide me.
Thanks
 
Old 09-15-2008, 01:54 PM   #2
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Primary suspect right now is carriage returns. Learn vi and stop editing scripts in Windows, ok?

Run:
$ dos2unix your_script_here

... and try again.
 
Old 09-15-2008, 02:47 PM   #3
andremun
LQ Newbie
 
Registered: Sep 2008
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks... Now it works...
I'm going to learn vi now
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
error: unexpected token `newline' CarlosV Programming 4 05-17-2011 03:47 AM
syntax error near unexpected token Aigarzs Linux - Newbie 3 01-12-2008 03:39 PM
Why am I getting an unexpected token error in this script? projektdotnet Programming 7 09-01-2007 03:32 PM
syntax error near unexpected token `else' josedias Programming 3 09-11-2006 07:09 PM
syntax error near unexpected token ` mattyspatty Programming 8 05-07-2006 05:19 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:18 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration