Newbie to Shell Scripts
I grew up a MS DOS user and have "graduated" to linux.
I'm trying to create a shell script to run Jin, the java chess interface, which currently requires 'java -jar jin.jar' to run, and requires this command in the current directory. I'm a lazy bum, so naturally I want to write a shell script that runs this, which I can then place a link to on my Desktop and click on when I want to run Jin. I don't know where to start! Is there a users guide to Shell Scripts someone can direct me to please? Taaaaa, WildChild |
Quote:
http://mirrors.sunsite.dk/ldp/HOWTO/...tro-HOWTO.html |
If you usually have a terminal open, make an alias:
% alias jin="java -jar jin.jar" % jin A simple bash script: #!/bin/bash java -jar jin.jar Desktop shortcut depends on your window manager. |
Basic Guide
Thanks,
That looks ok. Also, is there anything I need to watch out for when dealing with scripts and Directories with spaces in their names, ie. /home/wildchild/sub folder/ Cheers, WildChild |
Path names with spaces must be quoted, or
they will be treated as two (or more) file names. Three easy ways to quote: "file name", 'file name', file\ name The "ls" command has an option to give you the last format. Many programs also allow a "-print0" option to return "C" strings. |
Quote:
Advanced Bash-Scripting Guide Have fun... |
Here's my script
#!/bin/bash cd /home/wildchild/Program\ Files/jin-2.11b/ java -jar jin.jar it seems I have to cd into the directory if I want to create a link to the script or it gives me the error "cannot find file 'Program'" can anyone offer any improvement to this script, say for instance, to allow me to move the entire jin directory and still have the script work? |
Maybe tell java where to find the .jar file, like this:
java -classpath "/home/wildchild/Program Files/jin-2.11b" -jar jin.jar |
I don't see how that will help, as if I move my jin directory, the script will have the wrong path.
|
You declare you want this shortcut to run from anywhere;
but you do not want to "cd", or include the actual path. You can't selectively change one part of your configuration and not another; you must set the CLASSPATH somewhere for java to know where to look: 1) in your local user environment, or 2) in the local/global shortcut, or 3) in the global Config.sys, or 4) in the global AutoExec.bat. |
All times are GMT -5. The time now is 06:28 AM. |