简体   繁体   中英

bash script exits before completion

I'm new to shell script, and I tried to understand why it stopped running after the command which submits a job into Gaussian (a computational chem program). Here is my code.

echo "hi, the script is running..."
location=$(dirname $1)
echo $location
g09 <<EEE 
%chk=test2
$(cat $1)
EEE
echo $?
echo "done"
echo "need help??????" >tttt.txt

It doesn't show the last three echos, while the computational program terminates normally.

My assumption is when the program quits, my script is terminated as well. But is it possible? How should I get it around??

    **Last login: Tue Jun 21 17:56:40 on ttys001
    -bash: ulimit: open files: cannot modify limit: Invalid argument
    lab-chem067-02:~ gaussian$ /Users/gaussian/Desktop/test.sh /Users/gaussian/Desktop/cd7041a_cd7041a.gjf 
    hi, the script is running...**
    /Users/gaussian/Desktop
     Entering Gaussian System, Link 0=g09
     Initial command:
     /Applications/gaussian/g09/l1.exe "/Applications/gaussian/scratch/Gau-2788.inp" -scrdir="/Applications/gaussian/scratch/"
     Entering Link 1 = /Applications/gaussian/g09/l1.exe PID=      2790.

     Copyright (c) 1988,1990,1992,1993,1995,1998,2003,2009,2013,
                Gaussian, Inc.  All Rights Reserved.

     This is part of the Gaussian(R) 09 program.  It is based on
     the Gaussian(R) 03 system (copyright 2003, Gaussian, Inc.),
     the Gaussian(R) 98 system (copyright 1998, Gaussian, Inc.),
     the Gaussian(R) 94 system (copyright 1995, Gaussian, Inc.),
     the Gaussian 92(TM) system (copyright 1992, Gaussian, Inc.),
     the Gaussian 90(TM) system (copyright 1990, Gaussian, Inc.),
     the Gaussian 88(TM) system (copyright 1988, Gaussian, Inc.),
     the Gaussian 86(TM) system (copyright 1986, Carnegie Mellon
     University), and the Gaussian 82(TM) system (copyright 1983,
     Carnegie Mellon University). Gaussian is a federally registered
     trademark of Gaussian, Inc.

     This software contains proprietary and confidential information,
     including trade secrets, belonging to Gaussian, Inc.

     This software is provided under written license and may be
     used, copied, transmitted, or stored only in accord with that
     written license.

     The following legend is applicable only to US Government
     contracts under FAR:

                        RESTRICTED RIGHTS LEGEND

     Use, reproduction and disclosure by the US Government is
     subject to restrictions as set forth in subparagraphs (a)
     and (c) of the Commercial Computer Software - Restricted
     Rights clause in FAR 52.227-19.

     Gaussian, Inc.
     340 Quinnipiac St., Bldg. 40, Wallingford CT 06492


     ---------------------------------------------------------------
     Warning -- This program may not be used in any manner that
     competes with the business of Gaussian, Inc. or will provide
     assistance to any competitor of Gaussian, Inc.  The licensee
     of this program is prohibited from giving any competitor of
     Gaussian, Inc. access to this program.  By using this program,
     the user acknowledges that Gaussian, Inc. is engaged in the
     business of creating and licensing software in the field of
     computational chemistry and represents and warrants to the
     licensee that it is not a competitor of Gaussian, Inc. and that
     it will not use this program in any manner prohibited above.
     ---------------------------------------------------------------


     Cite this work as:
     Gaussian 09, Revision D.01,
     M. J. Frisch, G. W. Trucks, H. B. Schlegel, G. E. Scuseria, 
     M. A. Robb, J. R. Cheeseman, G. Scalmani, V. Barone, B. Mennucci, 
     G. A. Petersson, H. Nakatsuji, M. Caricato, X. Li, H. P. Hratchian, 
     A. F. Izmaylov, J. Bloino, G. Zheng, J. L. Sonnenberg, M. Hada, 
     M. Ehara, K. Toyota, R. Fukuda, J. Hasegawa, M. Ishida, T. Nakajima, 
     Y. Honda, O. Kitao, H. Nakai, T. Vreven, J. A. Montgomery, Jr., 
     J. E. Peralta, F. Ogliaro, M. Bearpark, J. J. Heyd, E. Brothers, 
     K. N. Kudin, V. N. Staroverov, T. Keith, R. Kobayashi, J. Normand, 
     K. Raghavachari, A. Rendell, J. C. Burant, S. S. Iyengar, J. Tomasi, 
     M. Cossi, N. Rega, J. M. Millam, M. Klene, J. E. Knox, J. B. Cross, 
     V. Bakken, C. Adamo, J. Jaramillo, R. Gomperts, R. E. Stratmann, 
     O. Yazyev, A. J. Austin, R. Cammi, C. Pomelli, J. W. Ochterski, 
     R. L. Martin, K. Morokuma, V. G. Zakrzewski, G. A. Voth, 
     P. Salvador, J. J. Dannenberg, S. Dapprich, A. D. Daniels, 
     O. Farkas, J. B. Foresman, J. V. Ortiz, J. Cioslowski, 
     and D. J. Fox, Gaussian, Inc., Wallingford CT, 2013.

     ******************************************
     Gaussian 09:  EM64M-G09RevD.01 24-Apr-2013
                    21-Jun-2016 
     ******************************************
     %chk=test2
     -------------------------------
     #P HF/STO-3G 6d 10f NoSymm FChk
     -------------------------------
     1/38=1/1;
     2/12=2,15=1,17=6,18=5,40=1/2;
     3/6=3,8=22,11=9,16=1,25=1,30=1/1,2,3;
     4//1;
     5/5=2,38=5/2;
     6/7=2,8=2,9=2,10=2,28=1/1;
     99/5=1,9=1/99;
  ==============omitted part, chem software output=================
     WOMEN HOLD UP HALF THE SKY. -- MAO TSE TUNG
     Job cpu time:       0 days  0 hours  0 minutes  1.5 seconds.
     File lengths (MBytes):  RWF=      7 Int=      0 D2E=      0 Chk=      1 Scr=      1
     Normal termination of Gaussian 09 at Tue Jun 21 18:05:20 2016.
    **lab-chem067-02:~ gaussian$** 

Alright, so it's been a while and I think I should close this question since by the suggestion from @Charles Duffy , I added shebang line and clean up the format by checking if there's any cr/lf problem (I was writing the script on Windows). Yes, that solved the problem. Thank you Charles!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM