text: user-1: I'm trying to execute pymol from a shell script (and it is not working). I'm not executing the script on  PyMOL but even if I do this, it doesn't work neither. However, if instead of a script the commands are manually written in PyMOL, everything goes well.
  Here is the code:
  #!/bin/bash
  pwd
  echo 'fetch 1OYT 
  remove resn HOH
  h_add elem O or elem N
  select ligand, resn FSN 
  ' > scriptt.pml
  pymol scriptt.pml
  
  One of the problems, you will see, is that PyMOL does not remove the water molecules. Another issue is that the program does not exit. Do you have any idea what's going on there?
  
  user298: Your shell script is fine, and works as expected. The reason it hangs is that you aren't telling PyMol to exit after running your script, so it's still running and waiting for the next command. Just add a quit at the end and it should work:
  #!/bin/bash
  pwd
  echo 'fetch 1OYT 
  remove resn HOH
  h_add elem O or elem N
  select ligand, resn FSN 
  select prot, 1OYT and not ligand, 
  save lig.pdb, ligand 
  save prot.pdb, prot
  quit
  ' > scriptt.pml
  pymol scriptt.pml
  obabel prot.pdb -xr -O prot.pdbqt 
  obabel lig.pdb -O lig.pdbqt
  echo 'babel conversion is finished'
  
  
original_text: -1: <p>I'm trying to execute pymol from a shell script (and it is not working). I'm not executing the script on  PyMOL but even if I do this, it doesn't work neither. However, if instead of a script the commands are manually written in PyMOL, everything goes well.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>#!/bin/bash
  pwd
  echo 'fetch 1OYT 
  remove resn HOH
  h_add elem O or elem N
  select ligand, resn FSN 
  ' &gt; scriptt.pml
  pymol scriptt.pml
  </code></pre>
  
  <p>One of the problems, you will see, is that PyMOL does not remove the water molecules. Another issue is that the program does not exit. Do you have any idea what's going on there?</p>
   298: <p>Your shell script is fine, and works as expected. The reason it hangs is that you aren't telling PyMol to exit after running your script, so it's still running and waiting for the next command. Just add a <code>quit</code> at the end and it should work:</p>
  
  <pre><code>#!/bin/bash
  pwd
  echo 'fetch 1OYT 
  remove resn HOH
  h_add elem O or elem N
  select ligand, resn FSN 
  select prot, 1OYT and not ligand, 
  save lig.pdb, ligand 
  save prot.pdb, prot
  quit
  ' &gt; scriptt.pml
  pymol scriptt.pml
  obabel prot.pdb -xr -O prot.pdbqt 
  obabel lig.pdb -O lig.pdbqt
  echo 'babel conversion is finished'
  </code></pre>
  