Bash脚本没有运行tclsh

Rya*_*ahn 1 bash tcl

我可以正确地在远程家庭上运行bash.我在远程主机上安装了TCL但是无法运行TCL.当我运行这个脚本时,我没有错误.

#!/bin/bash
ssh root@XXX.XXX.XXX.XXX << EOF
echo "Connected";
echo "CD TO ~";
cd ~;
echo "Create text file";

script='
        set data "This is some test data.\n"
        set filename "test.txt"
        set fileId [open $filename "w"]
        puts -nonewline $fileId $data
        close $fileId
exit 0'

tclsh << HERE
$script
echo "Exit";

exit
EOF
Run Code Online (Sandbox Code Playgroud)

Cha*_*ffy 5

默认情况下,Heredocs会在其中扩展变量,因此除非您在外部脚本中导出变量,否则将更[open $filename "w"]改为open "w"](以及其他地方的类似更改)filename.如果您不希望发生扩展,请引用您的印记:

ssh root@XXX.XXX.XXX.XXX <<'EOF'

script='content'

# intentionally not quoting this sigil, since in this case expansion is desired
tclsh <<HERE
$script
HERE

EOF
Run Code Online (Sandbox Code Playgroud)