• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Bestpractice for writting linux script in a java code?

 
Rajesh Pattabi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rajesh Pattabi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Rajesh Pattabi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, not following. What would the attacker do, exactly? TellTheDetails
 
Rajesh Pattabi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulf,

please see the below link for more information.

http://cwe.mitre.org/top25/#CWE-78
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12102
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic