Can't make a script run
I am installing a Java program which I have used before on other OSes. It comes with a sh script to start it, and the script is properly identified in the first line as an sh script. The file is quite short, and I have reviewed its contents for accuracy; it seems to be in order.
I assume that the file has to be made executable, and I have done this. For the time being, there are three "x"s in the permissions. From the command line, in the directory in which the script resides, I try to run the script by typing its name. This gets me an instant retort as follows: ***** bash: run: command not found ***** So it is clear that I have misunderstood something somewhere, and done, or omitted to do, something, though I can't see where there was much room for error. What must I do to run this script? |
If the directory isn't in your path and assuming the script is call run, you need to type "./run" (without the quotes).
|
Quote:
Nonintuitive, but reasonable after you know it. I never would have tumpled to it by myself, because it looks reduncant. I'll change the name of the script to something unique, and add its location to the path, which I would have had to do in the end anyway. Many thanks!! |
Quote:
***** : bad interpreter: no such file or directory ***** Since I can see that the script "run" is right there in front of me, something must indeed be bad. How to fix it? |
try "sh run".
|
Quote:
***** #!/bin/sh # cd /home/stan/bin/genj java -classpath ./lib/genj.jar genj.app.App ***** I have found in the meantime some literature on shell scripts. It seems to be telling me that, because of the irst line, I should be able to run it simply by typing its name, as I tried initially (and unsuccessfully. It isn't clear to me why that failed. But there are even more serious confusions which are not touched on by the documentation I have found. Firstly, the cd line doesn't work at all. It gets an error message saying "no such file or directory". There IS such a directory, and I am running the script from it. Since this is an absolute directory specification, it should leave me just where I am, and make no complaint. But it doesn't matter what directory I specify, I get the same error message. The jave line gets an error message from the JVM, indicating that it couldn't find genj.app.App. This line is correct, although I may have abused some Linux rule in writing it exactly so. The lib directory is, as it says, one directory down from the directory I am in (and which the cd line was meant to bring me to if I had started from some other directory). The entry point (genj.app.App) is correct. These two logether work in other OSes, given only the obvious directory changes from system to system, and turning "/" into "\". While problem of the cd line is script-related, and presumably belongs in this forum, the problem of the java line would probably be better put somewhere else. But I see no forum here or elsewhere where the connection between Linux and Java are addressed. If someone would like to direct me to one, I would be overjoyed and grateful. |
Change the first line to #!/bin/bash and you might have more luck.
|
Quote:
Not so. "sh" is an alias for "bash". |
<writes quick hello world to test...>
You're not wrong - never knew that one! |
Quote:
Quote:
Quote:
|
Quote:
|
If the shell script isn't executable and . isn't in your $PATH, the shell won't run it automatically.
As bash is just a very souped up sh, I guess distro maintainers didn't see a point of including them both (the BSDs do). |
Quote:
|
Right ... that's true. The one time I ran into that, it wound up being a permission problem, but no idea in this case.
|
Several possibilities... one or more of the libs that the shell
is linked against have the wrong permissions. The partition he's trying to run it from is mounted noexec (I occasionally do that with home ;} for machines that others have accounts on when I have to suspect that they may be installing unwanted software) ... Cheers, Tink |
All times are GMT -5. The time now is 11:48 AM. |