繁体   English   中英

使用OdiOSCommand执行Powershell脚本

[英]Executing powershell script using OdiOSCommand

我创建了一个批处理文件,该文件首先调用cmd,然后应调用powershell,读取特定文件,然后创建一个将其编码为UTF-8的新文件。 手动执行此脚本可以正常工作。

Oracle Data Integrator支持OSCommands,因此我使用该元素来调用为此目的而创建的批处理脚本(自动化原因)。 您可以在下面找到批处理脚本的代码:

cmd 
powershell
"Get-Content D:\mrapateatrit\SOURCE_FILES\Puntoret.txt | Set-Content -Encoding utf8 D:\mrapateatrit\SOURCE_FILES\Puntoret_utf8.txt"
exit;

当我执行调用此脚本的ODI程序包时,它会将其输出到文件:

C:\Users\lori\Desktop>cmd  
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\lori\Desktop>

这意味着它仅在代码中调用cmd,但没有读取powershell命令。 该元素可以采用的一些参数:

Command to execute: I provided the path of the batch script
Output file directory: path provided
Error file directory: Error file path provided
Working directory: desktop path provided

如果有人可以帮助我创建通过ODI调用该脚本的理想方法,那将真的很有帮助。

使用以下代码解决了该问题: cmd /c C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -command "Get-Content D:\\mrapateatrit\\SOURCE_FILES\\Puntoret.txt | Set-Content -Encoding utf8 D:\\mrapateatrit\\SOURCE_FILES\\Puntoret_utf8.txt"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM