This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to execute a command from Java in Linux?

 
ying lam
Ranch Hand
Posts: 85
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to execute a command from Java in linux, like this:
String cmd = ..... ;
Process x = Runtime.getRuntime().exec( cmd );

But my problem is I need to setup some shell variables for my Linux command?

How can I do that?

And I am running this Runtime.getRuntime().exec() in my own servlet.

Thank you for any tips.
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can run the command inside of a short shell script, which would set up the shell variables, and then call the actual command.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic