Executing python script from java passing arguments -


i asked days ago executing python script java. solved problem partially. now, not able pass parameter , make script anything.

my script has receive xbee frame , send serial port. tested script in shell , works fine. so, doing: sudo python script.py frame, frame sent.

now, tried same java, , fails. code is:

process p; //system.out.println(packet.tostring()); try{     stringbuffer p1 = new stringbuffer();     string[] cmd = {"/bin/bash", "-c", "echo pass | python script.py b'", packet.tostring(), "'"};       p = runtime.getruntime().exec(cmd);      bufferedreader br = new bufferedreader(new inputstreamreader(p.getinputstream()));     string s = br.readline();     p.waitfor();     p.destroy(); } catch (exception e) {} 

i have add b' before argument , ' after it. packet stringbuffer string tostring method.

i need run root because uses serial port , if not, says me have not permission.

do know how it? tried write file word when run script nothing happends, makes me think doesn't run properly.


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -