Bash script exiting prematurely when calling another script inside it -


itemprop = "text">

I type a bash script that tells another party script:

  #! / Bin / Bash Echo "Hi" ./script-two.sh "Hello!"   

The problem I have is that this ever "Hello!"

I think the reason for this is ./script-two.sh (which I have not written) is changing any way out or shell. I have included this script at the end of this post.

Is there a way I can gurentee that my execution will continue after implementing script-two.sh?

I have seen in using the net command, but I do not consider it completely useable.

Thanks,

How to

The script of the content here- Two.sh

  #! / Bin / sh # This file is a part of the DITA Open Toolkit Project hosted on #SourceFor.org. # See the accompany license.txt file for the applicable license. # (C) Copyright IBM Corp. 2006 All Rights Reserved. Export DITA_HOME = cwd if "[$ {DITA_HOME: +1}"! = "1"]; Then the echo "DITA_HOME environment variable is empty or not set"; Quit 127; & Amp; Fi echo Get $ DITA_HOME cd "$ DITA_HOME" # DITAOT home directory absolute path DITA_DIR = "` pwd` "that echo $ DITA_DIR [" $ DITA_DIR "-f / tools / ant / bin / ant] & amp; [! -X "$ DITA_DIR" / Device / Ent / Bin / Ent]; Then chmod + x "$ DITA_DIR" / tools / ant / bin / ant-fi export ANT_OPTS = "- Xmx512m $ ANT_OPTS" export ANT_OPTS = "$ ANT_OPTS -Djavax.xml.transform.TransformerFactory = net.sf.saxon.TransformerFactoryImpl" Exports ANT_HOME = "$ DITA_DIR" / tool / ant export path = "$ DITA_DIR" / tool / ant / bin: "$ PATH" NEW_CLASSPATH = "$ DITA_DIR / lib: $ DITA_DIR / lib / dost.jar: $ DITA_DIR / lib / commons-codec -1.4. jar: $ DITA_DIR / lib / resolver.jar: $ DITA_DIR / lib / icu4j.jar "NEW_CLASSPATH =" $ DITA_DIR / lib / Saxon / saxon9.jar: $ DITA_DIR / lib / Saxon / saxon9- Dome .jar: $ NEW_CLASSPATH "NEW_CLASSPATH =" $ DITA_DIR / lib / Saxon / saxon9-dom4j.jar: $ DITA_DIR / lib / Saxon / saxon9-jdom.jar: $ NEW_CLASSPATH "NEW_CLASSPATH =" $ DITA_DIR / lib / Sachs / Saxon9- s9api.jar: $ DITA_DIR / lib / Saxon / saxon9-sql.jar: $ NEW_CLASSPATH "NEW_CLASSPATH =" $ DITA_DIR / lib / Saxon / saxon9-xom.jar: $ DITA_DIR / lib / Saxon / saxon9-xpath. jar: $ DITA_DIR / lib / Saxon / saxon9-xqj.jar: $ NEW_CLASSPATH "if test -n" $ CLASSPATH "export CLASSPATH =" $ NEW_CLASSPATH ":" $ CLASSPATH "and export CLASSPATH =" $ NEW_CLASSPATH "fi" $ Open "   

It looks like script-two.sh Installing an Entry Build environment.

I think the author believes that this build environment sets, then you manually type your build command, then exit Type.

I say because the lower line of script-two.sh is:

  "$ SHELL"   

Those who start a new shell.

Try running your script, then type exit I think that you call it Hello! After typing will see the exit print.


I'm feeling that you are trying to do this:

  #! / Bin / Bash Echo "Hi" ./script-two.sh ant & lt; Some RGS & gt;   

To do this, what you really want to do is the source, by changing it:

  ./ script-two.sh   

to

  script- dwo.sh   

for example.

  #! / Bin / bash echo "hi" script - two. Ant & lieutenant; Some RGS & gt;   

However, you will need to edit and change script-two.sh :

  "$ SHELL" < / Code>  

to:

  case $ 0 * script-two.sh) # Executed, start a new shell with the new environment "$ shell"; ; *) # Sourced, do not start a new shell ;; Esac   

so that it starts only if the script is being run like ./ script-two.sh , but if it's like Not being sourced Code>. Script-dwo.sh .

Or if you can not change script-two.sh at all, then you can:

  #! / Bin / bash Echo "Hi" script- dwo.sh & lt; / Dev / null ant & lt; Some args & gt;   

The move will be "shell" because there is no input in it.


In addition to

  exporting DITA_HOME = CWD   

does not seem right to me.

This should probably

  export DITA_HOME = $ (PWD)   

or

  Export DITA_Home = `PWD`   

(both are equal)

Comments