Linux Bash在共享会话中运行多个远程脚本

Linux Bash在共享会话中运行多个远程脚本,linux,bash,Linux,Bash,我正在尝试构建一个由多个外部文件构成的userdata加载序列: $ aws s3 cp s3://my-bucket/init.sh - | bash $ echo "Some other custom commands" $ aws s3 cp s3://my-bucket/more-stuff.sh - | bash 现在在init.sh中有一些我需要使用的核心函数,它们在其他脚本部分中不可用,因为每一个都是不同的bash会话 有没有办法在一个bash会话中执行所有这些脚本和命令?您应该

我正在尝试构建一个由多个外部文件构成的
userdata
加载序列:

$ aws s3 cp s3://my-bucket/init.sh - | bash
$ echo "Some other custom commands"
$ aws s3 cp s3://my-bucket/more-stuff.sh - | bash
现在在
init.sh
中有一些我需要使用的核心函数,它们在其他脚本部分中不可用,因为每一个都是不同的bash会话


有没有办法在一个bash会话中执行所有这些脚本和命令?

您应该下载脚本,然后使用
源代码运行。然后,所有定义的变量和函数都可用于其他脚本

$ aws s3 cp s3://my-bucket/init.sh ~/s3_init.sh
$ chomd 750 ~/s3_init.sh
$ source ~/s3_init.sh
...

对于aws s3中的cp选项,请参见

是的,我想也许有一种方法可以执行远程文件,并使其创建变量,调用此远程文件的脚本可以访问这些变量