Am 18.08.2013 18:12, schrieb James:
> The second scenario - I never even see the GUI. I am using jmol.jar, not
> the applet (although I gather the distinction between the two or at
> least packaging of the applet, has changed recently).
>
The easiest way to invoke a program and get the results back in Perl 
without using a file is using backticks to invoke the program.

Example, invoking the linux/unix 'ls' command:
   my $dir_list = `ls -1`;

The scalar variable $dir_list will contain everything what the 'ls' 
command printed to standard output, namely a listing of the files in the 
current working directory, as a string.

If You use the array variable @dir_list instead (array context), 
multiline output should be filled into the array, one line per array 
element.

The problem with Jmol is here, that in my experience standard output and 
standard error are both printed to standard output if Jmol isn't invoked 
interactively with GUI. And as far as I know you cannot change this 
behaviour.
For single line output this is no problem, because you can rather easily 
print a special string before the actual output, e.g.:

java -jar JmolData.jar -n -J 'print "DATA: Hello from Jmol"'

(Your Jmol directory needs to be the current working directory.)

For multiple line output it is a little bit more difficult. But you can 
define your own Jmol print function that does prepend "DATA: " before 
printing each line, e.g.:

function my_print(value) {
   for (var z in value.lines) {
     print "DATA: " + z;
   }
}

Example (tested with Jmol 13.1.12):

java -jar JmolData.jar -n -J 'function my_print(value) {for (var z in 
value.lines) { print "DATA:\t" + z; }} load =1deh; my_print(script("show 
orientation"));'

If you are connected to the Internet "load =1deh" loads PDB entry 1deh 
from the RCSB server. Otherwise replace "=1deh" by a file on your computer.

Details on the command line switches for Jmol are available here:
http://wiki.jmol.org/index.php/Jmol_Application

In Perl it could look like this (not tested):

--------------
   chdir("my_jmol_path");
   my @jmol_output = `java -jar JmolData.jar -n -J 'function 
my_print(value) {for (var z in value.lines) { print "DATA:\t" + z; }} 
my_print("Hello from Jmol"); load =1deh; my_print(script("show 
orientation"));'`;

   foreach my $jmol_output_line(@jmol_output) {
     my $data = substr($jmol_output_line, 5);
     print $data;
   }
--------------

Regards,
Rolf

-- 

Rolf Huehne
Postdoc

Leibniz Institute for Age Research - Fritz Lipmann Institute (FLI)
Beutenbergstrasse 11
07745 Jena, Germany

Phone:   +49 3641 65 6205
Fax:     +49 3641 65 6210
E-Mail:  [email protected]
Website: http://www.fli-leibniz.de

           Scientific Director: Prof. Dr. K. Lenhard Rudolph
        Head of Administration: Dr. Daniele Barthel
Chairman of Board of Trustees: Dennys Klein

VAT No: DE 153 925 464
Register of Associations: No. 296, Amtsgericht Jena
Tax Number: 162/141/08228


------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to