We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › start program via open with param?
Page Index Toggle Pages: 1
start program via open with param?? (Read 1874 times)
start program via open with param??
Jan 24th, 2010, 9:41am
 


Hello all!

 String[] params ={      "C:\\Programme\\POV-Ray for Windows v3.62\\bin\\pvengine-sse2.exe", SketchPath1 + fileName     }     ;

 open(params);

I just try to
start the program porvRay via open with params.

Without the params it works, with them, it doesn't.

Is it because of the spaces in the /&%§ path?

I tried everything, even writing a batch-file...

Thanks!

Greetings!

Chris
Re: start program via open with param??
Reply #1 - Jan 24th, 2010, 10:16am
 
Perhaps you can use .INI file
A quick glance at the options suggest you can try:
Code:
String[] params = { "C:/Programme/POV-Ray for Windows v3.62/bin/pvengine-sse2.exe", "/RENDER", SketchPath1 + fileName }; 

Re: start program via open with param??
Reply #2 - Jan 24th, 2010, 10:19am
 


doesn't work......

....................
Re: start program via open with param??
Reply #3 - Jan 24th, 2010, 10:32am
 

it would work
Code:
  String[] params = {     
   "C:/Programme/POV-Ray for Windows v3.62/bin/pvengine-sse2.exe", ""   } ;

 open(params);


but then, obviously the pov-file is missing....

Is it maybe because of the space in the first param? What about the
""-thing?

Thanks!    Undecided

Re: start program via open with param??
Reply #4 - Jan 24th, 2010, 11:31am
 
Have you tried to run that on the command line?
> "C:/Programme/POV-Ray for Windows v3.62/bin/pvengine-sse2.exe" "file to render"

Normally, spaces in params doesn't matter, Java takes care of that.
Re: start program via open with param??
Reply #5 - Feb 1st, 2010, 1:43am
 


Hello!

It still doesn't work    Cry

I want to start pov-ray from processing and render a file.

So I need something like:

I work with a param-array, but it boils down to:

open ( PathPOV, "/RENDER", fileToRender ) ;

I work under Windows XP.

Is it more wise to go for

open (...  c:\\programs\\
or
open (... c:\programs\
or
open (... c:/programs/

Does the renderfile-path need the same \\-convention?

I can't get to work:
renderfilepath = renderfilepath.replaceAll( "\\", "/" );

Any help appreciated.

Chris


Re: start program via open with param??
Reply #6 - Feb 1st, 2010, 2:15am
 
Perhaps you can answer my question... Or is it unclear?

First and last open forms are OK, I prefer the last one, easier to type and to read. The middle one can't work (will tell "illegal character", supposing you are trying to do an escape sequence like \n).
But if the path is in Windows form and already in a string, just leave it as is.

Side note: although you don't need it, for the record, you need to do:
renderfilepath.replaceAll( "\\\\", "/" );
because replaceAll takes a regex and \ has a special meaning in regexes... Why Sun haven't replaced \ by some other character in their regex implementation is beyond me...

Also check that SketchPath1 + fileName is really what you expect it to be (println it).
Re: start program via open with param??
Reply #7 - Feb 1st, 2010, 4:56am
 
Hello!

Thanks for your reply!

I was away the last days and I am now on another PC that doesn't have POV-Ray, so I couldn't check with the command-line (or the Run-function) yet. My apologies.  Embarrassed

I'll try this evening... I should post my Code...   Undecided

Greetings,

Chrisir



Re: start program via open with param??
Reply #8 - Feb 1st, 2010, 10:48am
 
Hello,

this is working with Windows Run Command:

"C:\Programme\POV-Ray for Windows v3.62\bin\pvengine-sse2.exe" /RENDER "M:\Eigene Dateien\Processing\4Tests\Math3Db\output.pov" /EDIT  "M:\Eigene Dateien\Processing\4Tests\Math3Db\output.pov" /NR

It says render and open in editor (NR being norestore of former loaded files in POV-Ray). Windows needs the "" because of the spaces in the path.

Greetings, Chris

Wink
Re: start program via open with param??
Reply #9 - Feb 1st, 2010, 11:20am
 



What we want  =======================================
"C:\Programme\POV-Ray for Windows v3.62\bin\pvengine-sse2.exe" /RENDER "M:\Eigene Dateien\Processing\4Tests\Math3Db\output.pov" /EDIT  "M:\Eigene Dateien\Processing\4Tests\Math3Db\output.pov" /NR

What we do ==========================================

void WriteToFile ( String MyText ){

 // Write to file

 final String fileName = "output.pov";

 // for save
 PrintWriter output;

 int i = 13;
 int i2 = 10;  
 char c = char(i);
 char c2 = char(i2);
 String SketchPath1 = sketchPath("");

 // Create a new file in the sketch directory
 output = createWriter(fileName);  
 String Buffer = MyText;
 String ReplaceWith = " " +  c + c2;
 output.println(Buffer.replaceAll ("\n", ReplaceWith )); // Write to the file
 output.flush(); // Writes the remaining data to the file
 output.close(); // Finishes the file

   String[] params = {
   "C:\\Programme\\POV-Ray for Windows v3.62\\bin\\pvengine-sse2.exe" ,  "/RENDER" , "" + SketchPath1 + fileName + "" , "/EDIT" ,  "" + SketchPath1 + fileName + "" , "/NR"     }  
 ;
 println (params);  
 open(params);

} // function

What we get  =======================================

PeasyCam v0.8.1

Start preparing Povray Polygons

Now the files...
M:\Eigene Dateien\Processing\4Tests\Math3Db\output.pov
M:\Eigene Dateien\Processing\4Tests\Math3Db\output.pov
!!!!!  M:\Eigene Dateien\Processing\4Tests\Math3Db\output.pov
[0] ""C:\Programme\POV-Ray for Windows v3.62\bin\pvengine-sse2.exe""
[1] " /RENDER "
[2] ""M:\Eigene Dateien\Processing\4Tests\Math3Db\output.pov""
[3] " /EDIT "
[4] ""M:\Eigene Dateien\Processing\4Tests\Math3Db\output.pov""
[5] " /NR"
Finished preparing Povray


PeasyCam v0.8.1

Start preparing Povray Polygons

Now the files...
M:\Eigene Dateien\Processing\4Tests\Math3Db\output.pov
M:\Eigene Dateien\Processing\4Tests\Math3Db\output.pov
!!!!!  M:\Eigene Dateien\Processing\4Tests\Math3Db\output.pov
[0] ""C:\Programme\POV-Ray for Windows v3.62\bin\pvengine-sse2.exe""
[1] "/RENDER"
[2] ""M:\Eigene Dateien\Processing\4Tests\Math3Db\output.pov""
[3] "/EDIT"
[4] ""M:\Eigene Dateien\Processing\4Tests\Math3Db\output.pov""
[5] "/NR"
Finished preparing Povray

PeasyCam v0.8.1

Start preparing Povray Polygons

Now the files...
M:\Eigene Dateien\Processing\4Tests\Math3Db\output.pov
M:\Eigene Dateien\Processing\4Tests\Math3Db\output.pov
!!!!!  M:\Eigene Dateien\Processing\4Tests\Math3Db\output.pov
[0] "C:\Programme\POV-Ray for Windows v3.62\bin\pvengine-sse2.exe"
[1] "/RENDER"
[2] "M:\Eigene Dateien\Processing\4Tests\Math3Db\output.pov"
[3] "/EDIT"
[4] "M:\Eigene Dateien\Processing\4Tests\Math3Db\output.pov"
[5] "/NR"
Finished preparing Povray
Re: start program via open with param??
Reply #10 - Feb 1st, 2010, 12:50pm
 

Oh! I solved it!

Thank you all!
Smiley


void WriteToFile ( String MyText ){

 // Write to file

 final String fileName = "output.pov";

 // for save
 PrintWriter output;

 int i = 13;
 int i2 = 10;  
 char c = char(i);
 char c2 = char(i2);
 String SketchPath1 = sketchPath("");

 // Create a new file in the sketch directory
 output = createWriter(fileName);  
 String Buffer = MyText;
 String ReplaceWith = " " +  c + c2;
 output.println(Buffer.replaceAll ("\n", ReplaceWith )); // Write to the file
 output.flush(); // Writes the remaining data to the file
 output.close(); // Finishes the file
 String[] params = {
   "C:\\Programme\\POV-Ray for Windows v3.62\\bin\\pvengine-sse2.exe" ,  "/RENDER" , "" + SketchPath1 + fileName + "" , "/EDIT" ,  "" + SketchPath1 + fileName + "" , "/NR"                               }  
 ;
 println (params);  
 // from http://www.coderanch.com/t/419192/Java-General/java/Runtime-getRuntime-exec-String-command
 Runtime rt = Runtime.getRuntime();  //  
 try {  
   rt.exec(params  ) ; // "mspaint " + strPictureLocation);  
 }
 catch (IOException ioe) {  
   ioe.printStackTrace();    
 }    

} // function
Re: start program via open with param??
Reply #11 - Feb 2nd, 2010, 1:17am
 
Mmm, you are doing the same thing than open(), except this one adds cmd /c before the parameters.
This doesn't work well with GUI applications...
I supposed that you were doing a headless (no GUI) rendering in pure command-line way.
Glad you sorted out the issues yourself.
Re: start program via open with param??
Reply #12 - Feb 17th, 2010, 3:02pm
 
Hello,

I couldn't get it working with open.
I tried approx. 3 evenings...
Now it works.

Thanks for your reply!

Highly appreciated!

Greetings,

Chrisir

Page Index Toggle Pages: 1