From: Axel Kohlmeyer (akohlmey_at_cmm.chem.upenn.edu)
Date: Mon Aug 13 2007 - 19:11:53 CDT

On Mon, 13 Aug 2007, Arneh Babakhani wrote:

AB> Hi,
AB>
AB> I have a script that runs just fine in the tcl console gui, by the
AB> command: play measureHBonds.tcl
AB> (it writes to a file, I get the output that I expect).
AB>
AB> But when I try to run the script from the command line and put the job
AB> in the background, by:
AB> vmd -dispdev text -e measureHBonds.tcl >& myjob.job &
AB>
AB> it doesn't run properly (nothing is written to the output file). Any
AB> idea why this works in the tcl console gui but not from the command line?

arneh,
try adding a quit to the end of your script and redirecting
input from /dev/null before backgrounding with &.

cheersm
  axel.

AB>
AB> Script is pasted below if you want to look at it,
AB>
AB> Thanks,
AB>
AB> Arneh
AB>
AB> rm HBondData.txt
AB> set outfile [open "HBondData.txt" w]
AB>
AB> foreach f [find Pdbfiles/ -name "*.pdb"] {
AB> mol load pdb $f
AB> set receptor [atomselect top "all not resname UNK"]
AB> set ligand [atomselect top "resname UNK"]
AB> set HBONDS [measure hbonds 3.0 75 $ligand $receptor]
AB> set TrueHBONDS [llength $HBONDS]
AB>
AB> if {$TrueHBONDS > 2} {
AB> set Donor [lindex $HBONDS 0]
AB> if {$Donor >= 1} {
AB> set Acceptor [lindex $HBONDS 1]
AB>
AB> set DonorSelection [atomselect top "index $Donor"]
AB> set DonorIndex [$DonorSelection get index]
AB> set DonorName [$DonorSelection get name]
AB>
AB> set AcceptorSelection [atomselect top "index $Acceptor"]
AB> set AcceptorIndex [$AcceptorSelection get index]
AB> set AcceptorName [$AcceptorSelection get name]
AB> set AcceptorResID [$AcceptorSelection get resid]
AB> set AcceptorResName [$AcceptorSelection get resname]
AB>
AB> set NumberofHBonds [llength $DonorIndex]
AB>
AB> puts $outfile "--STARTHERE--"
AB> puts $outfile "$f"
AB> puts $outfile " DonorIndex: $DonorIndex"
AB> puts $outfile " DonorName: $DonorName"
AB> puts $outfile " AcceptorIndex: $AcceptorIndex"
AB> puts $outfile " AcceptorName: $AcceptorName"
AB> puts $outfile " AcceptorResID: $AcceptorResID"
AB> puts $outfile "AcceptorResName: $AcceptorResName"
AB> puts $outfile " NumberofHBonds: $NumberofHBonds"
AB> }
AB> }
AB> mol delete all
AB> }
AB>
AB> close $outfile
AB>
AB>
AB>

-- 
=======================================================================
Axel Kohlmeyer   akohlmey_at_cmm.chem.upenn.edu   http://www.cmm.upenn.edu
   Center for Molecular Modeling   --   University of Pennsylvania
Department of Chemistry, 231 S.34th Street, Philadelphia, PA 19104-6323
tel: 1-215-898-1582,  fax: 1-215-573-6233,  office-tel: 1-215-898-5425
=======================================================================
If you make something idiot-proof, the universe creates a better idiot.