LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Running script problem (https://www.linuxquestions.org/questions/linux-general-1/running-script-problem-89333/)

McGyver 09-04-2003 05:07 PM

Running script problem
 
Hello everybody...

I would like your help with the following problem...

I've created a Java application which starts running from a class named "main"...

In order to avoid the procedure of opening a terminal whenever a user wants to run the application, I've written the following very simple bash script:

//Script start

#! /bin/sh
java main

//Script end

The problem is that when I run the script from a terminal everything is fine, but if I double click on it from inside Konqueror or create a link on the desktop I get an error "Couldn't find the program 'main'"...

I would appreciate any help anyone could provide...

Thank you all in advance...

Dark_Helmet 09-04-2003 05:18 PM

You can't have a space between the exclamation mark and /bin/sh.

As you have it in the message, it's the equivalent of a DOS batch file. The first line is interpreted as a comment (because of the space), and then runs "java main".

McGyver 09-04-2003 05:44 PM

Hello Dark_Helmet...

Thank you for your immediate reply...

I corrected my script according to your post, but the problems still exists: double clicking on the script's icon in Konqueror produces the same error as before...

trickykid 09-04-2003 05:46 PM

Most likely Konq doesn't know exactly where "java main" is located at on your system. Have you tried putting the full path to it?

McGyver 09-04-2003 05:57 PM

Hello trickykid...

Thanks for your reply, too...

However I had no luck... Problem persists...

'java' is the Java's bytecode interpreter and is located in /usr/java/j2sdk1.4.2/bin...
'main' is the class the interpreter has to run in order for the application to start...

I suppose 'main' in passed as an argument to the 'java' program...
Has this anything to do with the problem?

And why the script has the desired effect when run from a terminal window?

McGyver 09-04-2003 06:00 PM

Something else I just figured out...

I renamed the script from 'main' to 'main.sh' and the error message changed to "Couldn't find the program 'main.sh'"...

I hope this gives some clue about what is goind on...

McGyver 09-04-2003 06:04 PM

I solved it!

I examined a similar script and added a line "cd `dirname $0`" before "java main"...

Don't ask me why this worked, I do not know!

Thank you all for your posts...


All times are GMT -5. The time now is 12:46 AM.