Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.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
使用sshpass导出shellscript中的参数化变量_Shell_Variables_Parameterized_Sshpass - Fatal编程技术网

使用sshpass导出shellscript中的参数化变量

使用sshpass导出shellscript中的参数化变量,shell,variables,parameterized,sshpass,Shell,Variables,Parameterized,Sshpass,我有一个类似于下面代码的用例。需要将参数化变量/标识符从shell脚本导出到远程shell脚本。我使用了以下代码,但无法导出值。请建议怎么做 A.sh脚本1 当我硬编码值时,我在远程shell脚本中获取该值 export directory='/data/2017-7-7/' 我想导出参数化变量,请建议如何实现。谢谢,请删除第一个尾端的引号: 根据bash手册: 这里有文件 [……] 此处文件的格式为: [n]<<[-]word here-document delimit

我有一个类似于下面代码的用例。需要将参数化变量/标识符从shell脚本导出到远程shell脚本。我使用了以下代码,但无法导出值。请建议怎么做

A.sh脚本1 当我硬编码值时,我在远程shell脚本中获取该值

export directory='/data/2017-7-7/' 

我想导出参数化变量,请建议如何实现。谢谢,请删除第一个尾端的引号:

根据bash手册:

这里有文件

[……]

此处文件的格式为:

[n]<<[-]word
    here-document
delimiter
无参数和变量扩展、命令替换、算术 扩展,或对word执行路径名扩展。如果任何部分 word被引用,分隔符是word上删除引号的结果, 此处文档中的行不会展开。如果单词是 未加引号,此处文档的所有行都受参数约束 展开、命令替换和算术展开,字符 序列\被忽略,并且\必须用于引用 字符\、$和`

[……]

export directory='/data/2017-7-7/' 
sshpass -p asdf ssh rock@host.com << ENDSSH
export directory="$1"
sh /../B.sh
ENDSSH
[n]<<[-]word
    here-document
delimiter