Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entering cshell from bash

Tags:

bash

csh

I have a bash script and need to run some commands in cshell inside it.

#!/bin/bash

echo entering_to_cshell
csh
echo in_cshell
exit
echo exited_from_cshell

Why doesn't this script run as expected? It only prints entering_to_cshell and it doesn't exit from cshell.

like image 691
Ashot Avatar asked Mar 22 '26 17:03

Ashot


1 Answers

By using

csh

you start a new subshell where your script isn't executed. That's why none of your following commands are executed. Your script waits for this subshell to end which, as you noted, never happens.

Try

csh -c "echo in_cshell"

This way you don't create a new subshell which isn't impacted by your script.

like image 172
m3adow Avatar answered Mar 25 '26 12:03

m3adow



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!