LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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-04-2003, 05:07 PM   #1
McGyver
LQ Newbie
 
Registered: Jun 2003
Location: Athens, Greece
Distribution: Red Hat Linux 9
Posts: 6

Rep: Reputation: 0
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...
 
Old 09-04-2003, 05:18 PM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
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".
 
Old 09-04-2003, 05:44 PM   #3
McGyver
LQ Newbie
 
Registered: Jun 2003
Location: Athens, Greece
Distribution: Red Hat Linux 9
Posts: 6

Original Poster
Rep: Reputation: 0
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...
 
Old 09-04-2003, 05:46 PM   #4
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
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?
 
Old 09-04-2003, 05:57 PM   #5
McGyver
LQ Newbie
 
Registered: Jun 2003
Location: Athens, Greece
Distribution: Red Hat Linux 9
Posts: 6

Original Poster
Rep: Reputation: 0
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?
 
Old 09-04-2003, 06:00 PM   #6
McGyver
LQ Newbie
 
Registered: Jun 2003
Location: Athens, Greece
Distribution: Red Hat Linux 9
Posts: 6

Original Poster
Rep: Reputation: 0
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...
 
Old 09-04-2003, 06:04 PM   #7
McGyver
LQ Newbie
 
Registered: Jun 2003
Location: Athens, Greece
Distribution: Red Hat Linux 9
Posts: 6

Original Poster
Rep: Reputation: 0
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...
 
  


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
Problem running ATI driver test script chrisjbzero Linux - Newbie 1 03-28-2004 03:23 PM
Bash Script: Problem running variable command containing "" Paasan Programming 2 01-21-2004 01:45 AM
Apache CGI Problem : Browser not running script Zaknafien Linux - Software 3 12-31-2003 01:16 PM
Shell script running via crontab problem. thetruethugg Linux - Software 13 12-19-2003 08:56 PM
Have problem running .pl perl script in apache adrianmak Linux - Software 4 11-10-2003 09:31 AM

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

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