Thanks for your reply. Yes. I am talking about SLURM.
I tried your first code (completely perl ones). It gives the following error:
Can't exec "gaussian": No such file or directory at....
resp.com is only one job for run on cluster. I have about 1000 jobs. So I have to convert it to perl script.