我能够正确地在一个偏远的家庭上跑步。我已经在远程主机上安装了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发布于 2015-01-29 02:59:46
默认情况下,Heredocs会扩展它们中的变量,因此,除非在外部脚本中导出了一个[open $filename "w"]变量,否则您的open "w"]将更改为open "w"](以及其他地方的类似更改)。如果您不希望这种扩展发生,请引用您的信号:
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
EOFhttps://stackoverflow.com/questions/28206277
复制相似问题