LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-05-2003, 09:18 AM   #1
aamehl
LQ Newbie
 
Registered: Sep 2003
Distribution: RH 9.0
Posts: 24

Rep: Reputation: 15
bash scripts won't run


Hi all,
I have two scripts that come were sent to me by a friend they start a database which he built for me.

On his system they run fine on my system I get the following errors.

[aamehl@bzq-218-14-208 nigun]$ ./nigunStart
: bad interpreter: No such file or directory
[aamehl@bzq-218-14-208 nigun]$

[aamehl@bzq-218-14-208 nigun]$ sh nigunStart
nigunStart: line 9: syntax error: unexpected end of file
[aamehl@bzq-218-14-208 nigun]$

this script runs another script
[aamehl@bzq-218-14-208 nigun]$ ./start
: bad interpreter: No such file or directory
[aamehl@bzq-218-14-208 nigun]$
[aamehl@bzq-218-14-208 nigun]$ sh start
'tart: line 24: syntax error near unexpected token `
'tart: line 24: `
[aamehl@bzq-218-14-208 nigun]$

the program being run is xindice an xml database.

He says that it works fine for him. I tried fiddling with permissions to no avail.
If someone has an idea I can send them the files to check.
Thanks
Aaron
 
Old 09-05-2003, 09:46 AM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Are these scripts in your "nigun" directory to be executed from? Are they executable? What kind of scripts are they, can you post one of them here, etc?
 
Old 09-05-2003, 10:40 AM   #3
aamehl
LQ Newbie
 
Registered: Sep 2003
Distribution: RH 9.0
Posts: 24

Original Poster
Rep: Reputation: 15
thanks for answering

they are all in the same directory and I tried making them executable but I don't always remember correctly 755???


I will post the scripts on sunday.
Thanks
Aaron
 
Old 09-05-2003, 06:47 PM   #4
lyle_s
Member
 
Registered: Jul 2003
Distribution: Slackware
Posts: 392

Rep: Reputation: 55
There's another thread you can look at in the mean time:

http://www.linuxquestions.org/questi...threadid=52263

Lyle
 
Old 09-06-2003, 05:36 AM   #5
shep
LQ Newbie
 
Registered: Sep 2003
Distribution: redhat
Posts: 7

Rep: Reputation: 0
You don't have to remember cmod 755 or whatever. Just type 'man chmod' and it's all right there. Personally, 'chmod u+x' is a lot easier for me to remember.
 
Old 09-06-2003, 12:31 PM   #6
Ciccio
Member
 
Registered: Nov 2002
Location: Paraguay
Distribution: Mandrake 10
Posts: 573

Rep: Reputation: 30
It's just practice... and for the simple ones 777, 700, 770, 755, 222 722 I use the numbers... otherwise.... I read the man :P
 
Old 09-06-2003, 12:57 PM   #7
aamehl
LQ Newbie
 
Registered: Sep 2003
Distribution: RH 9.0
Posts: 24

Original Poster
Rep: Reputation: 15
thanks
Aaron sometimes I don't try a man and only later think of it...

Thanks
 
Old 09-06-2003, 01:03 PM   #8
aamehl
LQ Newbie
 
Registered: Sep 2003
Distribution: RH 9.0
Posts: 24

Original Poster
Rep: Reputation: 15
Ok I looked at the other thread and it is exactly my problem.
But one would hope that xintice which is an apache project would run on linux bash?

but maybe my friend wrote it in dos (also doubtful)
I however can't find a from dos command...

I will now post the two scripts. and I guess ls -l couldn't hurt
AA
 
Old 09-06-2003, 01:05 PM   #9
aamehl
LQ Newbie
 
Registered: Sep 2003
Distribution: RH 9.0
Posts: 24

Original Poster
Rep: Reputation: 15
[The nigunStart script:
aamehl@bzq-218-14-208 nigun]$ cat nigunStart
#!/bin/bash
export XINDICE_HOME=$(pwd)
export CP=$(pwd)/toren.jar
for i in ./lib/*.jar ;do export CP=$CP:$i ; done
for i in ./java/lib/*.jar ;do export CP=$CP:$i ; done
xterm -e ./start &
java -cp $CP toren.DataEntryApp

[aamehl@bzq-218-14-208 nigun]$


--------------------------------------
the start script
[aamehl@bzq-218-14-208 nigun]$ cat start
#!/bin/sh
if test -z "$XINDICE_HOME"; then
XINDICE_HOME=`dirname $0`
export XINDICE_HOME
fi

echo "Xindice Loader"
echo "=============="
echo
echo "Environment"
echo "-----------"
echo "XINDICE_HOME = " $XINDICE_HOME

if test -f $XINDICE_HOME/config/xindice.pid; then
echo "A Xindice instance is already running with PID" `cat $XINDICE_HOME/config/xindice.pid`
exit
fi

CLASSPATH=$XINDICE_HOME/classgen:$XINDICE_HOME/config:$CLASSPATH

# Read in the list of Xindice Jars to include in the CLASSPATH
JARS=`ls -1 $XINDICE_HOME/java/*.jar`
for jar in $JARS

do
CLASSPATH=$jar:$CLASSPATH ;
done

# Read in the extra VM paramters for starting the program
VMPROPS=""
if test -f $XINDICE_HOME/config/vm.cfg; then
PROPS="`cat $XINDICE_HOME/config/vm.cfg`"
for prop in $PROPS
do
VMPROPS="$VMPROPS $prop"
done
fi

echo "CLASSPATH = " $CLASSPATH
echo
echo "Starting Xindice"
echo "----------------"

cd $XINDICE_HOME

echo $$ > $XINDICE_HOME/config/xindice.pid

RESTART=1

server_shutdown() {
SHUTDOWN_CMD=""
INSTANCES="`cat $XINDICE_HOME/config/instances.cfg`"
for instance in $INSTANCES
do
$XINDICE_HOME/bin/xindiceadmin shutdown -c /$instance 1> /dev/null 2> /dev/null
done
}

server_restart() {
RESTART=1
server_shutdown
}

trap "echo; echo 'Attempting Server Shutdown'; server_shutdown" 2 15
trap "echo; echo 'Attempting Server Restart'; server_restart" 1

while test $RESTART
do
RESTART=

java -Xms16m -Xmx168m -Dxindice.home="$XINDICE_HOME" $VMPROPS -classpath "$CLASSPATH" org.apache.xindice.server.Xindice $* &

wait $!
done

trap 1 2 15
rm $XINDICE_HOME/config/xindice.pid
[aamehl@bzq-218-14-208 nigun]$

[aamehl@bzq-218-14-208 nigun]$ ls -l
total 116
drwxrwxrwx 2 aamehl aamehl 4096 Aug 11 23:26 bin
drwxrwxrwx 2 aamehl aamehl 4096 Aug 26 10:41 config
-rwxrwxrwx 1 aamehl aamehl 4825 Aug 12 06:20 database.sql
drwxrwxrwx 5 aamehl aamehl 4096 Aug 11 23:26 db
drwxrwxrwx 2 aamehl aamehl 4096 Aug 11 23:26 docs
drwxrwxrwx 2 aamehl aamehl 4096 Aug 19 15:52 java
drwxrwxrwx 2 aamehl aamehl 4096 Aug 19 15:53 lib
-rwxrwxrwx 1 aamehl aamehl 2743 Mar 14 2002 LICENSE
drwxrwxrwx 2 aamehl aamehl 4096 Aug 11 23:26 logs
-rwxrwxrwx 1 aamehl aamehl 229 Aug 12 07:43 nigunStart
-rwxrwxrwx 1 aamehl aamehl 38 Aug 31 23:20 nst
-rwxrwxrwx 1 aamehl aamehl 229 Aug 31 23:19 nst~
-rwxrwxrwx 1 aamehl aamehl 1031 Aug 12 06:45 README
-rwxrwxrwx 1 aamehl aamehl 1718 Aug 31 23:23 start
-rwxrwxrwx 1 aamehl aamehl 1718 Aug 31 23:23 start~
-rwxrwxrwx 1 aamehl aamehl 1802 Mar 14 2002 startup.bat
-rwxrwxrwx 1 aamehl aamehl 39662 Aug 12 05:33 toren.jar
-rwxrwxrwx 1 aamehl aamehl 139 Aug 31 23:20 tt.txt?
-rwxrwxrwx 1 aamehl aamehl 1411 Mar 14 2002 xindice.server
[aamehl@bzq-218-14-208 nigun]$

Thanks
AA
 
Old 09-06-2003, 02:16 PM   #10
lyle_s
Member
 
Registered: Jul 2003
Distribution: Slackware
Posts: 392

Rep: Reputation: 55
I'm pretty sure you have the DOS line ending problem.

I copied and pasted your nigunStart script into vi and saved it as nigunStart.unix. Naturally it has the normal Unix LF (line feed) to indicate line endings.

I ran it via ./nigunStart.unix and it ran; I got errors because I don't have the same setup as you, but it ran.

Then I made a copy of it with DOS CR LF endings (carriage return and line feed endings) via "todos < nigunStart.unix > nigunStart.dos".

Running the copy resulted in:
lyle@bowman:~/empty$ ./nigunStart.dos
: bad interpreter: No such file or directory

I also tried:
lyle@bowman:~/empty$ sh nigunStart.dos
nigunStart.dos: line 8: syntax error: unexpected end of file

This is exactly the behaviour in your original post.

To check what line ending convention a file has, use od -a. For example (I've highlighed what's important to notice in red, and we only need a few lines to see what we need to see):

lyle@bowman:~/empty$ od -a nigunStart.unix | head -2
0000000 # ! / b i n / b a s h nl e x p o
0000020 r t sp X I N D I C E _ H O M E =

and:

lyle@bowman:~/empty$ od -a nigunStart.dos | head -2
0000000 # ! / b i n / b a s h cr nl e x p
0000020 o r t sp X I N D I C E _ H O M E

You can use tr to get rid of the offending CR characters if you don't have the fromdos command (I used man ascii to figure out that CR is '\r'):

lyle@bowman:~/empty$ tr -d '\r' < nigunStart.dos > nigunStart.new
lyle@bowman:~/empty$ chmod 700 nigunStart.new
lyle@bowman:~/empty$ ./nigunStart.new

nigunStart.new runs as expected.

Lyle
 
Old 09-06-2003, 02:25 PM   #11
aamehl
LQ Newbie
 
Registered: Sep 2003
Distribution: RH 9.0
Posts: 24

Original Poster
Rep: Reputation: 15
wow thanks
Aaron
This group is great, I could never have figured it out on my own.
Aaron
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to run Bash scripts like thread in Java? nguyenzoro Linux - General 1 11-11-2005 02:08 AM
Cannot run install sh scripts, and bash is FUBAR...what to do? asdfjkl Linux - Software 5 11-20-2004 09:09 PM
Suitable place to run bash scripts Skyline Programming 7 01-21-2004 07:37 PM
How to Run perl scripts using bash Boudewijn Linux - Software 2 11-26-2003 03:37 AM
Install scripts do not run...BASH# no such command tmera Linux - General 1 12-17-2000 02:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:35 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