简体   繁体   中英

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. 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). 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:

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. 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

使用以下代码解决了该问题: 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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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