2016-06-21 191 views
0

我是shell腳本的新手,我試着理解爲什麼它在將作業提交到高斯(計算化學程序)的命令之後停止運行。 這是我的代碼。bash腳本在完成之前退出

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 

它不顯示最後三個回聲,而計算程序正常終止。

我的假設是當程序退出時,我的腳本也被終止。但是有可能嗎?我應該怎麼弄?

**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$** 
+0

您是否收到任何錯誤? –

+0

我沒有。終端日誌被添加到帖子中。 chem軟件告訴我「正常終止」,我懷疑它是否終止了我的腳本。 –

+3

你的腳本缺少一些相當重要的東西 - 比如一個shebang行。 '#!/ bin中/ sh'? '#!/ bin中/ bash'?它是'#!/ bin/sh -e'還是'#!/ bin/bash -e',偶爾?細節很重要! –

回答

0

好了,所以它已經有一段時間,我想我應該從@Charles達菲建議關閉這個問題,因爲,我添加家當行,並通過檢查,如果有任何CR/LF問題清理格式(我正在Windows上編寫腳本)。是的,這解決了問題。謝謝查爾斯!