This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Printing from Sun using Runtime  RSS feed

 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, so I had asked a question a few months ago about running a script on a Sun box and the answer was to use something along the lines of:

Process exec = Runtime.getRuntime().exec("script");

Now, I'm attempting to execute the following command:

postprint filename.tmp | lpr

through Java...and no matter how I do it using the above, I cannot get it to execute, yet when I do it just on the command line, it works fine.
I read some of what's here and saw there there might be an issue with me piping the output into lpr, so I tried using just lpr, and that didn't work either.
Anyone have any ideas why this might be failing?
 
Bartender
Posts: 3320
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The tutorial you provided a link to clearly states why piping won't work and also shows you a solution. I suggest you read page 4 of the tutorial again.
 
Eric Chang
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I understand why the piping doesn't work, however the tutorial didn't explain why just doing "lpr filename.txt" didn't work either...unless I'm guessing that the fact that lpr takes in arguments is the same problem as piping to a file.
I will scour that tutorial again to see if I missed something more.

Fake Edit: Yeah, that's exactly what it is...nevermind.

[ September 30, 2008: Message edited by: Eric Chang ]
[ September 30, 2008: Message edited by: Eric Chang ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!