How to run a csh script from a sh script

user3245776 picture user3245776 · Jan 28, 2014 · Viewed 37.8k times · Source

I was wondering if there is a way to source a csh script from a sh script. Below is an example of what is trying to be implemented:

script1.sh:

#!/bin/sh

source script2

script2:

#!/bin/csh -f

setenv TEST 1234
set path = /home/user/sandbox

When I run sh script1.sh, I get syntax errors generated from script2 (expected since we are using a different Shebang). Is there a way I can run script2 through script1?

Answer

anubhava picture anubhava · Jan 28, 2014

Instead of source script2 run it as:

csh -f script2