运行 通过 Powershell 在 Alteryx 中使用相对路径时出错
Error using relative paths in Alteryx when running through Powershell
我有一个 Powershell 脚本,它调用 Alteryx 分析应用程序(向导)并通过 .xml 将单个参数输入其中 - 用于执行此操作的方法是 here。
Alteryx 工作流中的输出工具设置为相对路径,用于将输出存储到 Input 和 Working 文件夹,它们是一个级别在应用本身之上,例如:
..\Input\FileName.yxdb
如果我打开 Alteryx 工作流并 运行 它,或通过界面 运行 应用程序,它工作得非常好,我的输出被正确存储。但是,运行使用代码
通过 Powershell 对其进行设置
$modules = "C:\Projects19\Modules"
cd $modules
AlteryxEngineCmd.exe .\Extract_Variables.yxwz .\_Version.xml
returns 出现以下错误:
Error - ToolId 5: Cannot access the folder .\Input\.
Error - ToolId 15: Cannot access the folder .\Working\.
Error - ToolId 24: Cannot access the folder .\Input\.
Error - ToolId 26: Cannot access the folder .\Input\.
尽管如果 运行 直接在工作流程中,相对路径工作正常。 Powershell 将 运行 Alteryx 工作流程正常,但无法保存输出。
作为测试,我将 Input 和 Working 文件夹移动到与应用程序本身相同的级别,这工作正常 -文件保存到这些测试文件夹 - 所以就好像 Powershell 不理解这两个点代表向上移动一个级别。其实我可以写
..............\Input\FileName.yxdb
它仍会输出到我与 Alteryx 应用程序本身一起创建的测试输入文件夹。有人知道为什么会这样吗?
通过如何使用 Start-Process
执行您的应用程序的示例来扩展我的评论。首先,关于文件结构的假设:
- C:\Projects19
|-- Modules
|-- AlteryxEngineCmd.exe
|-- Extract_Variables.yxwz
|-- _Version.xml
|-- Input
|-- FileName.yxdb
|-- Working
和代码:
$processParams = @{
FilePath = '.\Modules\AlteryxEngineCmd.exe'
ArgumentList = '.\Modules\Extract_Variables.yxwz', '.\Modules\_Version.xml'
WorkingDirectory = 'C:\Projects19'
NoNewWindow = $true
Wait = $true
PassThru = $true
}
Start-Process @processParams
注意:为了便于阅读,我使用了一种称为 splatting 的技术将所有参数从 hashtable
传递给 Start-Process
。
我发现这个问题是对语法的简单误解。我的工作目录如下:
- C:\Projects19
|-- Modules
|-- AlteryxEngineCmd.exe
|-- Extract_Variables.yxwz
|-- _Version.xml
|-- Input
|-- FileName.yxdb
|-- Working
Alteryx 向导然后需要在 Powershell 中调用,如下所示:
$modules = "C:\Projects19\Modules"
cd $modules
AlteryxEngineCmd.exe Extract_Variables.yxwz _Version.xml
注意调用向导和 .xml 文件时不需要 .\
。使用 .\
将成功调用该模块,但会影响其中设置的相对路径。
我有一个 Powershell 脚本,它调用 Alteryx 分析应用程序(向导)并通过 .xml 将单个参数输入其中 - 用于执行此操作的方法是 here。
Alteryx 工作流中的输出工具设置为相对路径,用于将输出存储到 Input 和 Working 文件夹,它们是一个级别在应用本身之上,例如:
..\Input\FileName.yxdb
如果我打开 Alteryx 工作流并 运行 它,或通过界面 运行 应用程序,它工作得非常好,我的输出被正确存储。但是,运行使用代码
通过 Powershell 对其进行设置$modules = "C:\Projects19\Modules"
cd $modules
AlteryxEngineCmd.exe .\Extract_Variables.yxwz .\_Version.xml
returns 出现以下错误:
Error - ToolId 5: Cannot access the folder .\Input\.
Error - ToolId 15: Cannot access the folder .\Working\.
Error - ToolId 24: Cannot access the folder .\Input\.
Error - ToolId 26: Cannot access the folder .\Input\.
尽管如果 运行 直接在工作流程中,相对路径工作正常。 Powershell 将 运行 Alteryx 工作流程正常,但无法保存输出。
作为测试,我将 Input 和 Working 文件夹移动到与应用程序本身相同的级别,这工作正常 -文件保存到这些测试文件夹 - 所以就好像 Powershell 不理解这两个点代表向上移动一个级别。其实我可以写
..............\Input\FileName.yxdb
它仍会输出到我与 Alteryx 应用程序本身一起创建的测试输入文件夹。有人知道为什么会这样吗?
通过如何使用 Start-Process
执行您的应用程序的示例来扩展我的评论。首先,关于文件结构的假设:
- C:\Projects19
|-- Modules
|-- AlteryxEngineCmd.exe
|-- Extract_Variables.yxwz
|-- _Version.xml
|-- Input
|-- FileName.yxdb
|-- Working
和代码:
$processParams = @{
FilePath = '.\Modules\AlteryxEngineCmd.exe'
ArgumentList = '.\Modules\Extract_Variables.yxwz', '.\Modules\_Version.xml'
WorkingDirectory = 'C:\Projects19'
NoNewWindow = $true
Wait = $true
PassThru = $true
}
Start-Process @processParams
注意:为了便于阅读,我使用了一种称为 splatting 的技术将所有参数从 hashtable
传递给 Start-Process
。
我发现这个问题是对语法的简单误解。我的工作目录如下:
- C:\Projects19
|-- Modules
|-- AlteryxEngineCmd.exe
|-- Extract_Variables.yxwz
|-- _Version.xml
|-- Input
|-- FileName.yxdb
|-- Working
Alteryx 向导然后需要在 Powershell 中调用,如下所示:
$modules = "C:\Projects19\Modules"
cd $modules
AlteryxEngineCmd.exe Extract_Variables.yxwz _Version.xml
注意调用向导和 .xml 文件时不需要 .\
。使用 .\
将成功调用该模块,但会影响其中设置的相对路径。