Executing PyMOL from a Shell script
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
' &gt; scriptt.pml
pymol scriptt.pml
obabel prot.pdb -xr -O prot.pdbqt 
obabel lig.pdb -O lig.pdbqt
echo 'babel conversion is finished'