Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 多个ssh命令中的cat不起作用_Linux_Bash_Shell_Ssh_Heredoc - Fatal编程技术网

Linux 多个ssh命令中的cat不起作用

Linux 多个ssh命令中的cat不起作用,linux,bash,shell,ssh,heredoc,Linux,Bash,Shell,Ssh,Heredoc,这可能是非常基本的,但不幸的是我不知道如何谷歌它 为什么下面的代码片段不能按预期工作?我的意思是,如何使cat指向远程文件 #!/bin/bash ssh user@remoteaddress << EOF mkdir sandpit cd sandpit echo "foo" > foo.txt echo `cat foo.txt` > foo2.txt EOF #/bin/bash sshuser@remoteaddressfoo.txt echo

这可能是非常基本的,但不幸的是我不知道如何谷歌它

为什么下面的代码片段不能按预期工作?我的意思是,如何使
cat
指向远程文件

#!/bin/bash

ssh user@remoteaddress << EOF
  mkdir sandpit
  cd sandpit
  echo "foo" > foo.txt
  echo `cat foo.txt` > foo2.txt
EOF
#/bin/bash
sshuser@remoteaddressfoo.txt
echo`cat foo.txt`>foo2.txt
EOF
将其用作:

ssh -t -t user@remoteaddress<<'EOF'
mkdir sandpit
cd sandpit
echo "foo" > foo.txt
cat foo.txt > foo2.txt
xargs kill < pid.txt
exit
EOF
ssh-t-tuser@remoteaddressfoo2.txt
xargs kill
如果在启动
EOF
时没有引号,则所有单词都将进行shell扩展,而反向引号将在当前shell中展开,而不是在ssh上展开。

将其用作:

ssh -t -t user@remoteaddress<<'EOF'
mkdir sandpit
cd sandpit
echo "foo" > foo.txt
cat foo.txt > foo2.txt
xargs kill < pid.txt
exit
EOF
ssh-t-tuser@remoteaddressfoo2.txt
xargs kill

如果在启动
EOF
时没有引号,则所有单词都会进行shell扩展,反向引号会在当前shell中扩展,而不是在ssh上扩展。

谢谢,这很有效。嗯,我实际上想做的是
kill`cat pid.txt`
。在这种情况下我该怎么办?现在我检查了编辑,一切都解决了。非常感谢。谢谢,这很有效。嗯,我实际上想做的是
kill`cat pid.txt`
。在这种情况下我该怎么办?现在我检查了编辑,一切都解决了。非常感谢你。