0

I have a main tcl script which calls multiple bash scripts. But I want to have everything in one place. Is there a way to directly implement my bash scripts inside the tcl script (as procs?) and somehow mark them as bash scripts? You obviously can't just put them inside procs and change nothing about them of course.

Another thing that has to be taken care of: some bash scripts need to be accesed as su, how could that be implemented?

I'm not looking for something like this: How to call bash commands from tcl script? - I just want my bash scripts as "isolated" procedures.

1 Answer 1

2

Put the bash script in a properly quoted string, then pass that to bash:

proc do_bash_script {} {
    set bash_script {
        echo $HOME
        getent passwd $USER
    }
    exec bash << $bash_script
}
do_bash_script

outputs

/home/jackman
jackman:x:1001:1001:Glenn Jackman:/home/jackman:/usr/local/bin/fish
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.