1
  #!/bin/csh -x
   exec bash
   source ~arovit/RTM_test/unit_RTM/fail.10/failure.001.sh
   exec csh
   <script continues...>

is there any other way to do so ?

2
  • As you already know, what you show won't work; the first exec replaces the script with a (probably interactive) bash. Commented Mar 15, 2011 at 12:18
  • 3
    See: C Shell Programming Considered Harmful. Commented Mar 15, 2011 at 12:21

2 Answers 2

6

If the whole purpose of the bash script is to export the relevant env variables, I'd suggest you run the script as bash, the call the following script using csh. E.g.:

#!/bin/bash
source ~arovit/RTM_test/unit_RTM/fail.10/failure.001.sh
csh -x your_csh_script.sh

If the bash script isn't exporting vars, and is simply performing some tasks, then do it the other way round:

#!/bin/csh -x
bash ~arovit/RTM_test/unit_RTM/fail.10/failure.001.sh
<script continues...>
Sign up to request clarification or add additional context in comments.

6 Comments

No it doesnot involve exporting env variable.
@aro: if the failure.001.sh script does not involve setting environment, why do you need to source it instead of just running it?
@Shawin :It works ! Thanks . Can you tell me what was wrong in my solution?
Okay lets consider a scenario where both are setting and using some env variables or in otherwords exporting env variables then what would be the solution?
@aro in your script, the issue is that exec bash will start up an instance of bash and passing on control to it. The remainder of the script is run as usual (using csh) only when that instance ends.
|
2

Just do this:

#!/bin/csh
bash -c 'source bash_source; exec csh'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.