File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Linux / UNIX and the fly likes What is the role of shell scripting in Java Programming ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "What is the role of shell scripting in Java Programming ?" Watch "What is the role of shell scripting in Java Programming ?" New topic
Author

What is the role of shell scripting in Java Programming ?

Don Singh
Greenhorn

Joined: Jun 18, 2011
Posts: 18
What is the role of shell scripting in Java Programming ?
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4646
    
    5

none?

What are you really asking?

I write little shell scripts on occasion, usually in Perl rather than bash, but I don't see them has having anything to do with Java programming.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

One could write a shell script to compile some Java code, but that wouldn't mean that compiling code was the role of shell scripting in Java.

And considering that many Java programmers can spend a whole lifetime without using, or even understanding, shell scripting, I just have to reject the assumption in that question. Namely, that shell scripting has any role in Java. (Let alone the other assumption, that it has exactly one role in Java.)
Don Singh
Greenhorn

Joined: Jun 18, 2011
Posts: 18
I mean , have been developing Java apps for almost 3 yrs now,never used unix shell . Recently heard about a java project requirement in Java xml unix, so was wondering what role unix has here ? The only thing I can think of is probably starting/stopping server....what else we can automate java run process through bat file in Windows, does shell scritping is for unix platforms ? But that would be 2 lines of code then why specifically mentioning Unix, I think there must be more to it ...Please comment
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

If you're reading a job posting where the position requires knowledge of shell scripting, this means that (assuming it's not just HR piling on stuff they know nothing about) the position requires building/maintaining one or more systems with extra-java components. For example, cron jobs, script-based file import/export processes, general OS housekeeping such as logfile rotation, and so forth.

Shell scripts are the "quick-and-dirty" way of getting things done and gluing things together. They're also a lowest-common-denominator programming facility, since almost all OS's have at least one shell language. You don't have to worry about whether a "shell script VM" is installed, because there isn't one. Usually.

Shell scripts are also important in tight spaces. For example, when the system is booting up, not all system resources are yet available, since the whole idea is that the boot process preps them an brings them online, To control the prep/startup functions, shell scripts are commonly used, since they don't require source code changes/recompiles to customize, and they'll often be much smaller than an executable binary file as well.


Customer surveys are for companies who didn't pay proper attention to begin with.
Don Singh
Greenhorn

Joined: Jun 18, 2011
Posts: 18
Thanks Tim...
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11430
    
  85

Your second post seems different from your first.

Unix skills are often listed in job requirements where there are back-end servers. For example, at my current job, when we deploy to the test environment, we may have to ssh to the test box to look at the log files. To look at the files we may want to use less, or grep, or tail the log in real-time, ... Someone with Unix skills can do all these easily - someone without Unix skills will have to learn the tools and commands.

Shell scripting is different - some jobs I have worked at have required it, others have not. Shell scripts can be useful during deployment procedures, or in error alerting.


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
jay vas
Ranch Hand

Joined: Aug 30, 2005
Posts: 407
shell scripts are required because they are the simplest way to program against an OS. no matter what *NIX OS you are running (ubuntu,fedora,os x,....) you can always write and run a shell script. Furthermore, the semantics of shell scripts are, of course, optimized for OS related tasks (like moving / copying / scanning files , setting permissions, and installing software ).

Try writing a java program that, for example, moves a all of the files from a directory that contain the word "apple" in them to another directory. In unix, a shell script using grep / mv can do this in two lines.

Of course, for applications, shell scripts are not the best. they are hard to read once they get complex, they are not good at conveying complex logic, they are platform dependent (*NIX only), and they can actually be quite dangerous .
Gaurav Raje
Ranch Hand

Joined: Jul 23, 2010
Posts: 136
I remember when I was working on my thesis, I had to read a lot of papers. Our college required us to have a webpage/site(JSP) for our progress. My advisor wanted me to write a review for each paper I read and post a review on my website(JSP).
I wrote a shell script which would parse through each txt file that I saved on a particular folder in my disk, and upload it using sftp to the webserver and post it in the required format.

Not that your project will be similar.. but in short shell is good for quick automation. Python works too. so do perl and others.

Many experienced programmers prefer writing millions of lines of code instead of a few lines of shell scripts.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Korn and Bash Shell are powerful programming languages which enable programmer's to write code that is executed directly by operating systems. When applications consist of components written in multiple programming languages such a Java, C, Oracle PL/SQL and Perl applicaiton, one or more shell scripts typically are "drivers" which glue everything together.

Aside, everything in Java is not always a web app or an EJB.
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4646
    
    5

Jimmy Clark wrote:Korn and Bash Shell are powerful programming languages which enable programmer's to write code that is executed directly by operating systems.

Close, (there are many others, csh, tsh, etc.) but not exactly right.

They are scripting tools, they accept input from the user and execute programs. But they are not "directly" executed by the operating system, at least by the usual definitions of operating system. When you run a shell, say the bash shell, you are executing it the context of the bash shell as a program. Its a user mode program, just like any other program. Some commands are implemented directly by the shell itself, most are implemented by separate programs with names like 'ls', 'grep', etc.

The reason that there are so many shells in Unix/Linux is that they are not special. Anyone can write one, and lots of people have when they didn't like one of the existing ones.
Don Singh
Greenhorn

Joined: Jun 18, 2011
Posts: 18
Thank You All for enlightening on the topic.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is the role of shell scripting in Java Programming ?