如何迭代文件夹内的所有文件和 运行 curl 命令来安装 AEM 包
How to iterate all files inside folder and run curl command to install AEM packages
我正在尝试创建一个 shell 脚本来迭代所有 zip 文件并使用 curl 命令将它们安装在 AEM 包管理器中。
下面的单个 curl 命令正在运行,它正在相应的 AEM 实例中正确安装包。
curl -u admin:admin -F file=@"content-ope.zip" -F name="content-ope.zip" -F force=true -F install=true http://localhost:4502/crx/packmgr/service.jsp
但我们必须安装许多 zip 文件,因此我们计划将它们全部保存在一个文件夹中,迭代所有 zip 文件并使用 curl 命令进行安装。尝试使用 while 和 for 循环,但无法使用 shell 脚本读取所有 .zip 文件。
有人对此有任何想法吗?
find . -name "*.zip" -maxdepth 1 -exec curl -u admin:admin -F file=@"{}" -F name="{}" -F force=true -F install=true http://localhost:4502/crx/packmgr/service.jsp ";"
节点,这将替换 ./foo.zip
而不是 foo.zip
。如果你需要剥离 ./
,你应该编写 shell-脚本包装你的 curl
命令,它接受 zip 文件名作为参数并在传递给 [之前从中剥离 ./
=14=].
您可以不使用 curl,而是将文件复制到 AEM 实例的安装文件夹中。这些将自动安装。 https://helpx.adobe.com/in/experience-manager/6-3/sites/administering/using/package-manager.html#FileSystemBasedUploadandInstallation
我写的正是那件事,请看这里:
https://gist.github.com/ahmed-musallam/07fbf430168d4ac57bd8c89d8be9bca5
#!/bin/bash
# this script will install ALL zip packages in current directory the AEM instance at 4502
for f in *.zip
do
echo "installing: $f"
curl -u admin:admin -F file=@"$f" -F name="$f" -F force=true -F install=true http://localhost:4502/crx/packmgr/service.jsp
echo "done."
done
我正在尝试创建一个 shell 脚本来迭代所有 zip 文件并使用 curl 命令将它们安装在 AEM 包管理器中。 下面的单个 curl 命令正在运行,它正在相应的 AEM 实例中正确安装包。
curl -u admin:admin -F file=@"content-ope.zip" -F name="content-ope.zip" -F force=true -F install=true http://localhost:4502/crx/packmgr/service.jsp
但我们必须安装许多 zip 文件,因此我们计划将它们全部保存在一个文件夹中,迭代所有 zip 文件并使用 curl 命令进行安装。尝试使用 while 和 for 循环,但无法使用 shell 脚本读取所有 .zip 文件。
有人对此有任何想法吗?
find . -name "*.zip" -maxdepth 1 -exec curl -u admin:admin -F file=@"{}" -F name="{}" -F force=true -F install=true http://localhost:4502/crx/packmgr/service.jsp ";"
节点,这将替换 ./foo.zip
而不是 foo.zip
。如果你需要剥离 ./
,你应该编写 shell-脚本包装你的 curl
命令,它接受 zip 文件名作为参数并在传递给 [之前从中剥离 ./
=14=].
您可以不使用 curl,而是将文件复制到 AEM 实例的安装文件夹中。这些将自动安装。 https://helpx.adobe.com/in/experience-manager/6-3/sites/administering/using/package-manager.html#FileSystemBasedUploadandInstallation
我写的正是那件事,请看这里:
https://gist.github.com/ahmed-musallam/07fbf430168d4ac57bd8c89d8be9bca5
#!/bin/bash
# this script will install ALL zip packages in current directory the AEM instance at 4502
for f in *.zip
do
echo "installing: $f"
curl -u admin:admin -F file=@"$f" -F name="$f" -F force=true -F install=true http://localhost:4502/crx/packmgr/service.jsp
echo "done."
done