I have to repeat following operation a lot of times, hence I want to automate it.sudo sutcshcd $workDirHere $workDir is set in ~/.tcshrc. I tried writing two shells scripts. Script1 is temp.sh#!/bin/bashsudo su./temp.cshScript2 is temp.csh#!/usr/bin/tcshtcshcd $workDirBut it doesn't work as expected i.e. I don't see the cshell prompt (still on bash prompt, unlike in without-script approach) neither have I CDed into $workDir. Any help/pointers?
How to change shells via script?
bash;sudo;csh
Use workDir=/dev/; sudo su -c tcsh -c cd $workDir; echo \$PWD to change the folder during script.Just remember to escape all $.EDITWhy wouldn't you do so:sudo ./tcsh.cshAnd inside tcsh.csh contains: #!/usr/bin/tcshcd $workDir  # need to set $workDir somewhere, depends on youblabla