HOW to run a bash-code in a c-shell script ??

Is there a way to run some code in a C-shell script by different shell, like bash?

I have that situation.
I have prepared and perfectly workable bash-skript that now I have to execute under C-shell script, divide it on steps and without creating a new files (with the bash-code parts.)

For example:

> cat c.sh
#!/bin/csh -f
echo " -- starting $0 --"
echo " .. before executing bash-code : "

/bin/bash/ -e <<END
  pair=123-456
      aRID=${pair%-*}
      iRID=${pair#*-}
  echo " aRID=$aRID; iRID=$iRID "
END

echo " -- exiting the $0 -- "
> ll c.sh
-rwxrwxrwx   1 abc1929  grsome       218 Feb  4 17:10 c.sh*
> c.sh
 -- starting ./c.sh --
 .. before executing bash-code :
pair: Undefined variable
>

Even with so simple statement it is already problems.
I need to execute much more advance and complicated processing!

I guess, the C-shell checking the syntax during the entering bash-code line in order to catch the 'END' line.
Maybe it is possible to disable it (the C-shell checking) and enable it after?

The option to have the code in single quotes is not usefull, too!
By that I would need to escape much: that will hightm!

Rewrite the bash script in c-shel - havy and long task!

I see only one option: brake the bash script on bansh of small files and process communication between them through env-variable or temporary files.

Disgusting solution!

Is there any other way?

Thank you!

get rid of the slash and -e after /bin/bash/

/bin/bash << END

instead of

/bin/bash/ -e

So, what?! It is going to prevent CSH from validating?!

--0207-091857:~/develop/src> c.sh
 -- starting ./c.sh --
 .. before executing bash-code :
pair: Undefined variable
--0207-091858:~/develop/src> cat c.sh
#!/bin/csh -f
echo " -- starting $0 --"
echo " .. before executing bash-code : "

/bin/bash  <<END
  pair=123-456
      aRID=${pair%-*}
      iRID=${pair#*-}
  echo " aRID=$aRID; iRID=$iRID "
END

echo " -- exiting the $0 -- "
--0207-092025:~/develop/src>

Is it possible, at all, to run under csh anithing else?! So dumb shell!!

Try this:

#!/bin/csh -f
echo " -- starting $0 --"
echo " .. before executing bash-code : "

/bin/bash  <<"#END"
  pair=123-456
      aRID=${pair%-*}
      iRID=${pair#*-}
  echo " aRID=$aRID; iRID=$iRID "
#END
1 Like

WORKS!!!!! (just it would like to have the #END in quotes: "#END".)

Whery much appreciate!!

What the staff is it? Where I can review about that?

I fiddled with it until it worked for me. Quoting the marker in ksh/bash says to not process the included data. I just hoped that csh might get that right too. I don't use csh and I don't know of any great docs for it.

Hi.

Many people suggest you avoid csh for scripting, scroll down the page: Csh Programming Considered Harmful. But if you must, consider the items below ... cheers, drl

Csh

TCSH: Welcome

Amazon.com: Unix C Shell Field Guide (9780139374685): Gail Anderson, Paul Anderson: Books