• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 129
1
Oracle Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 .
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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.
 
karthik Suryanarayanan
Ranch Hand
Posts: 129
1
Oracle Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Tim.. ;)
 
It would give a normal human mental abilities to rival mine. To think it is just a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic