It's not a secret anymore!*
The moose likes Linux / UNIX and the fly likes Shell Script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Shell Script" Watch "Shell Script" New topic
Author

Shell Script

Gagan Sabharwal
Ranch Hand

Joined: Apr 23, 2006
Posts: 48
Hi,

I am entering into the world of Unix OS. I intend to write a simple shell script which runs a java program. My java program takes three VM arguments and classpath of various directories.Let the root directory be ab_root.
Can some one please guide me to a sample script for such tasks ?

Also I am having a hard time mugging up basic unix commands. Not too sure if its the lack of interest or what.



Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

First, figure out how to run what you want to run from the command line. For example:



To turn that into a script, add a line identifying the script processor. For example:



If you would like to pass the arguments to the script, change it to:



Now you can run it as (assume the script is named "runmyapp"):



For more help, type "man bash" on the command line. You will get a lot of output, but everything about shell script syntax is in there.

Another hint: most Java apps are run by scripts. Study their scripts - look in the bin directory.


JBoss In Action
Gagan Sabharwal
Ranch Hand

Joined: Apr 23, 2006
Posts: 48
Thanks much Peter. I will try it out.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Shell Script
 
Similar Threads
FTP
Stack Memory
how to execute shell script from java class
handling Java child process execution
issue when calling shell script from java