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 Printing a file using Shell Script in Unix env called from a Java Application Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Reply Bookmark "Printing a file using Shell Script in Unix env called from a Java Application" Watch "Printing a file using Shell Script in Unix env called from a Java Application" New topic
Author

Printing a file using Shell Script in Unix env called from a Java Application

karthik Suryanarayanan
Ranch Hand

Joined: Oct 07, 2009
Posts: 88

Hi Guys,
I'm using a Java application which runs a shell script in Unix server for printing . In shell script I want to set the page length and remove the file if print was successful. My code is as follows .



I have tried with but here file is not getting deleted after printing. Hence i went for using if / else .

My question is if any exception occurs in shell script(OUT returns value other than 0) , how to return that value to my calling program in Java .


"Learning is a Culture where your Eagerness & Curiosity plays a major Role".
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 12513



The quotes on rm are for consistency, and like the quotes on the pr command, mainly server to ensure that filenames with spaces and other such artifacts are properly parsed.

Technically, this only detects whether the format and spool were successful. But once lpr hands off to the spooler, that's usually considered sufficient.


One of the most odious afflictions that Business has inflicted on the modern English language is "pro-active". Most of the time it's simply redundantly used in place of the simple old word "active". And a good deal of the rest of the time it means "You're not overworked enough yet, so go out and find more!"
karthik Suryanarayanan
Ranch Hand

Joined: Oct 07, 2009
Posts: 88

Thank you Tim.. ;)
 
 
subject: Printing a file using Shell Script in Unix env called from a Java Application
 
Threads others viewed
Setting printer paper length using unix commands
Output of telnet task
Linux + Java Printing
Running a .jar application from a unix shell script
Returning exit code to calling shell script
developer file tools