File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Bestpractice for writting linux script in a java code? 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 » Java » Java in General
Bookmark "Bestpractice for writting linux script in a java code?" Watch "Bestpractice for writting linux script in a java code?" New topic
Author

Bestpractice for writting linux script in a java code?

Rajesh Pattabi
Greenhorn

Joined: Apr 03, 2012
Posts: 9
hi all,
i want to write a linux script and execute that script in a java code. which is bestpractice to do it.
and my puropse for doing is i need to write on a file then i need to compare to another file and take the difference.

thanks in advance
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1648
    
    7

You can execute scripts like this



Or you can have a look at ProcessBuilder

If you are looking for a bit more you could also consider using Jython.


[How To Ask Questions][Read before you PM me]
Rajesh Pattabi
Greenhorn

Joined: Apr 03, 2012
Posts: 9
Hi Bill,
Thanks for your reply,
Currently i'm using by this way by inilizing my scripts in "myCommand" java code itself.
But its not safe and hackers easly hack code. so i'm looking for safe method.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41592
    
  55
Are you worried about someone altering the script? I assume it's as well protected as the Java code, so it's as vulnerable to attack as that. What attack scenario, specifically, are you trying to guard against?


Ping & DNS - my free Android networking tools app
Rajesh Pattabi
Greenhorn

Joined: Apr 03, 2012
Posts: 9
Hi Ulf,

I'm worring for OS Command Injection, that will happen to my code.

thanks for your question to describe me much better.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41592
    
  55
Sorry, not following. What would the attacker do, exactly? TellTheDetails
Rajesh Pattabi
Greenhorn

Joined: Apr 03, 2012
Posts: 9
Hi Ulf,

please see the below link for more information.

http://cwe.mitre.org/top25/#CWE-78
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11250
    
  16

Rajesh Pattabi wrote:please see the below link for more information.

Remember, your job when asking a question is to make it as easy as possible for someone to help you. Posing a link, saying "here, go read this", and expecting someone to then read a (rather lengthy) article, and THEN come back and make a guess as to what exactly your question is...doesn't really make it all that easy.

So, can you explain here, in your own words, what problem you are trying to avoid?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Bestpractice for writting linux script in a java code?