#!/usr/bin/expect # # (c) Sean Parkin 2013/10/19: xprun # # An 'expect' script that launches George Sheldrick's XP molecule editor program # and allows for automatic changing of things such as the way atoms are depicted # (ATYP command) that can't be set via the regular 'SXTL.INI' file (which is the # official way of fiddling with the default settings). # # Note: In the set up at UK, this 'expect' script is called by a separate script # named 'xp', which is used as a workaround to allow Sheldrick's XP to read .res # files that contain the new (unrecognized) SHELXL-2014 commands. The executable # for Sheldrick's XP must be renamed 'xpx' for this to work. See details in the # header for the xp_launcher script. For use on the Mac, the xp_launcher script # can also be set to start a short script that fixes the choppy 'proj' rotation. # That may sound a bit convoluted, but it works very well in practice. It would # perhaps be more concise to somehow include this all in the xp_launcher script, # but I don't know how to incorporate 'expect' inside bash in an elegant way. If # anyone knows how to do that, please tell. Supposed solutions found on the web # did not work well for me. # # 'Expect' is an extension of Tcl, and is the work of Don Libes at the NIST. # # Note: If you do not want to see the bypassed XP interactive blurbage scrolling # up the screen, just un-comment the line below with "# log_user 0" on it. # Note: The commented out "JOIN 5 $H" command that is given below works, but any # subsequent 'GROW' or "FMOL" will re-impose the default of "JOIN 1" so there is # little point in keeping it. # Note: The WSIZ command below is set for my Mac flaptop with my custom .xinitrc # but probably should be changed for any other computer/monitor resolution. The # commented out WSIZ works well with some lecture room projectors. # #log_user 0 set filename [lindex $argv 0] set xp_width [lindex $argv 1] spawn xpx $filename expect "XP>> " { send "FMOL/n\r" } expect "XP>> " { send "MPLN/n\r" } expect "XP>> " { send "ATYP -1\r" } expect "XP>> " { send "ATYP -2 \$C\r" } expect "XP>> " { send "ATYP 2 \$H\r" } expect "XP>> " { send "ATYP 2 \$D\r" } expect "XP>> " { send "LABL 1 400\r" } #expect "XP>> " { send "JOIN 5 \$H\r" } #expect "XP>> " { send "WSIZ 800\r" } expect "XP>> " { send "WSIZ $xp_width\r" } expect "XP>> " { send "PROJ\r" } interact