Changing shell from a script and running something from the new shell

Hi

We use "tcsh" shell . We do the following steps manually:
> exec ssh-agent zsh
> python "heloo.py" (in the zsh shell)

I am trying to do the steps above from a shell script

This is what I have so far

echo "Executing "
exec ssh-agent zsh
python "hello.py"
exit 0

Problem is step 2 above . The script just sits on the zsh prompts and waits for user to type "exit" and then runs the python script from tcsh shell (original shell)

What can i do in the script for it to run
python "hello.py" from the zsh shell instead?

Thanks in advance

I am not a csh or csh -derivative expert by any stretch of the imagination, but I don't understand why it matters at all which shell invokes python or why anyone would want to invoke a shell to invoke another shell to invoke python ???

Why isn't your script just:

ssh-agent python "hello.py"
exit 0

I am integrating SW components from two different teams. We want to use tcsh shell all the time but want to run this python framework in z shell (i don't know the reason for that)

Right now we do it manually . I am looking to put that in a shell script . But i am not able to achieve that yet

Thanks

That trick only works if the script is read from standard input.

sh -s <<EOF
echo "stuff"
# Some other command which reads the following lines
ssh user@host
echo \$HOSTNAME
EOF

This is because the command could not otherwise know what file to read from.

i apologize i don't follow what do you mean

Thanks !

I mean exactly what I said. If you do bash filename or ./filename it cannot "switch" to a new shell, language, whatever in the middle -- the new program will lose track of "filename".

You have to do bash -s < scriptname to allow it to change horses in midstream. The new program doesn't have to re-open filename -- it never opened it in the first place, they all just read from standard input.