简体   繁体   English

使用OdiOSCommand执行Powershell脚本

[英]Executing powershell script using OdiOSCommand

I created a batch file which firstly invokes cmd, then it should invoke powershell, read a specific file, and create a new file which encodes it to UTF-8. 我创建了一个批处理文件,该文件首先调用cmd,然后应调用powershell,读取特定文件,然后创建一个将其编码为UTF-8的新文件。 Executing this script manually it works fine. 手动执行此脚本可以正常工作。

Oracle Data Integrator supports OSCommands, so im using that element to call the batch script which I created for that purpose(automation reasons). Oracle Data Integrator支持OSCommands,因此我使用该元素来调用为此目的而创建的批处理脚本(自动化原因)。 Below you can find the code of the batch script: 您可以在下面找到批处理脚本的代码:

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

When I execute the ODI package which calls this script, it outputs this to file: 当我执行调用此脚本的ODI程序包时,它会将其输出到文件:

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

C:\Users\lori\Desktop>

This means that its only invoking cmd in the code, but it is not reading the powershell command. 这意味着它仅在代码中调用cmd,但没有读取powershell命令。 Some of the parameters which this element can take: 该元素可以采用的一些参数:

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

If someone could help me to create the ideal way to call that script through ODI would be really helpful 如果有人可以帮助我创建通过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