我在我试图执行的文件的目录中,我知道我正在使用正确的文本来执行位于正确位置的文件。该文件名为“modify search.cmd”,我正在执行:
./modify-search.cmd
但是,因为zsh只识别“echo”,所以我的“.cmd”文件中的其他命令无法识别,因此我的zsh shell状态为“找不到命令”。这是我的代码
modify-search.cmd
文件,减去用户特定的域/URL和管理密钥
@echo off
rem Set values for your Search service
set url=YOUR_SEARCH_URL
set admin_key=YOUR_ADMIN_KEY
echo -----
echo Updating the skillset...
call curl -X PUT %url%/skillsets/margies-skillset?api-version=2020-06-30 -H "Content-Type: application/json" -H "api-key: %admin_key%" -d @skillset.json
rem wait
timeout /t 2 /nobreak
echo -----
echo Updating the index...
call curl -X PUT %url%/indexes/margies-index?api-version=2020-06-30 -H "Content-Type: application/json" -H "api-key: %admin_key%" -d @index.json
rem wait
timeout /t 2 /nobreak
echo -----
echo Updating the indexer...
call curl -X PUT %url%/indexers/margies-indexer?api-version=2020-06-30 -H "Content-Type: application/json" -H "api-key: %admin_key%" -d @indexer.json
echo -----
echo Resetting the indexer
call curl -X POST %url%/indexers/margies-indexer/reset?api-version=2020-06-30 -H "Content-Type: application/json" -H "Content-Length: 0" -H "api-key: %admin_key%"
rem wait
timeout /t 5 /nobreak
echo -----
echo Rerunning the indexer
call curl -X POST %url%/indexers/margies-indexer/run?api-version=2020-06-30 -H "Content-Type: application/json" -H "Content-Length: 0" -H "api-key: %admin_key%"
以下是我执行命令时在终端中得到的输出:
./modify-search.cmd: line 1: @echo: command not found
./modify-search.cmd: line 3: rem: command not found
-----
Updating the skillset...
./modify-search.cmd: line 9: call: command not found
./modify-search.cmd: line 11: rem: command not found
./modify-search.cmd: line 12: timeout: command not found
-----
Updating the index...
./modify-search.cmd: line 16: call: command not found
./modify-search.cmd: line 18: rem: command not found
./modify-search.cmd: line 19: timeout: command not found
-----
Updating the indexer...
./modify-search.cmd: line 23: call: command not found
-----
Resetting the indexer
./modify-search.cmd: line 27: call: command not found
./modify-search.cmd: line 29: rem: command not found
./modify-search.cmd: line 30: timeout: command not found
-----
Rerunning the indexer
./modify-search.cmd: line 34: call: command not found
这对我来说很有意义,因为
echo
是zsh中的内置命令,因此不会执行@echo,而是执行通知文本消息。如何执行其他“.cmd”命令?
我正在为Microsoft Azure做培训实验室,所以我使用Azure CLI,并通过Visual Studio代码完成所有这些工作。此外,我在Visual Studio代码中安装了一个Powershell扩展,但也无法在那里工作。激活Powershell(通过zsh)后,我尝试执行:
command ./modify-search.cmd
该命令给我的输出与我在zsh上的可执行命令相同——“echo”语句有效,其他所有命令都返回“找不到命令”。
我完成实验室练习的低效解决方法是直接在“.cmd”代码中插入我的URL和管理密钥,无论我的文件在哪里:
%url%%admin_key%
并直接通过我的zsh shell(插入我的Azure CLI)执行调用,这在我上次遇到这个问题时起到了作用。
这是我第二次遇到这个问题,所以我想我会寻求帮助,这样我就可以有一个更有效的解决方案。请帮忙,有人吗?
编辑:更新,我的变通办法这次不起作用了!上次我执行Azure CLI命令,并在指定的部分之间替换身份验证数据以连接到我的帐户。这一次,我执行POST和PUT语句,但它们的工作方式不同。我得到以下输出:
zsh: no matches found: %url%/skillsets/margies-skillset?api-version=2020-06-30
第2版:好吧,我尝试使用VS代码调用REST API,您中的一些人可能已经从
modify-search.cmd
。我正在做一些与之相关的研究,这可能会让我找到解决方案。到目前为止,我已经:
-
为我的IDE安装了REST客户端扩展,VS代码
-
制作了一个不带扩展名的单独的“.rest”文件(这样文本文件就可以在此后将代码更改为“.erest”文件)。
我试图发送请求,但收到了
getaddrinfo ENOTFOUND echo
错误进步