How to configure copy command in nifi? - apache-nifi

i wants to know how to configure the executestream command for the below command.
copy C:\input\ip.txt \\host2\C:\destFolder\ip.txt
Actually if i open cmd prompt(AnyPath) then write this command it could worked in windows.
But i need to process those command in NiFi.
I tried those command in following attributes like below.
Command Arguments:copy C:\input\ip.txt \\host2\C:\destFolder\ip.txt
Command Path:C:\Windows\system32\cmd.exe
Argument Delimiter: space
Here after success of executestream command processed in OutputStream relationship but functionality of the command not issued.
In that command i have copy the file(ip.txt) from host1 into host2 machine.Generally if i run that command in cmd.exe then file copied into host2.
But if configure those parameters in ExecuteStreamcommand i have received outputstream but my command not run and file not moved into host2.
Can anyone guide me to resolve this?

you are trying to call a command without any streaming of the flow file.
so you need ExecuteProcess processor
Example with dir command:
Command : cmd
Arguments : /C dir c:\11
Delimiter : [space]
/C for cmd means call and exit

Command Arguments:copy C:\input\ip.txt \\host2\C:\destFolder\ip.txt
Add to front [/C]
Command Arguments:**/C** copy C:\input\ip.txt \\host2\C:\destFolder\ip.txt

Related

How to redirect Windows cmd output to a text file?

I am trying to monitor the cmd output of a certain executable .exe and use it for another process running at the same time.
The problem is that all cmd redirecting functions ( '>','>>','<' and '|') would only redirect the output after a successful return of the last command.
What I wanted to do is to generate some kind of streaming log of my cmd.
You can run in your process in background by using
start /b something.exe > somefile.txt
Windows 20H2: Redirection works fine when logged in as true administrator but will NOT work when logged in as a created administrative user. I have used it for years to redirect the output of a multi target backup system using Hobo copy to put the console output in a log file. I have never been able to get it to work successfully in Windows 10 ver 19 or 20 on a created administrative user.
You can prefix the command with "cmd /c" to start a new command prompt, and redirect the output of the command prompt:
cmd /c YOUR CODE > TextFileName.txt
Note : Use ONLY single greater than (>)
Since the output of cmd is going to TextFileName.txt.
Whereas this misses the error output, so you are not able to see : Request to UnKnown timed-out for each failed address.

Execute commands in Python without closing the CMD shell

I'm trying to execute commands sequentially through Python.
My aim is to do something like this:
command1
calculate something
command2
...
I want the CMD to remain opened after executing 'command1' , since 'command2' is dependent on 'command1'.
I've tried these answers with no results:
This one gives me the error:
ValueError: write to closed file
while executing two communicate commands.
Python Popen - how to execute commands in nested sub shell using python
Execute Commands Sequentially in Python
Thanks in advance!
I think you want this:
import os
os.system("start cmd /k command1 & command2")
unless you want it to quit after execting both of the commands:
import os
os.system("start cmd /c command1 & command2")
If you want to add more commands add & after command 2 and write your commands.
the first example will run both of the commands in the same window, but won't close it.
the second example will run both of the commands in the same window, and will close it afterwards

Piping output of process to file asynchronously in windows

I am trying to run a program using "start" and I want to have the output piped to a txt file, for example, I want to have the output of a simple http python server to be logged to a text file:
START cmd /c python -m SimpleHTTPServer 8000^>engineLog.txt
The above will print it to the log file but the problem with that is, it only prints it when the process finishes. Are there any way that I can store it to the log as it is running? Also is it possible to have it log in the txt file as well as having it print out in the console?
Give it a try:
START /b "Your title" "cmd /c python -m SimpleHTTPServer 8000 > engineLog.log | type engineLog.log"
Alternatively, you can get tee port for Windows.

Not Able to Run PowerShell Script from CMD

I want to execute a PowerShell script from Command Prompt. I have verified script from PowerShell, it worked fine. I went to script location and executed it as
./hyperv_disk_ops.ps1 -op 'getDiskAttachmentInfo' -vmid '{6612D0CB-BCC3-44D4-988B-526500578D54}' -disk_ids ("Microsoft:7B036CE0-5D67-46BA-AF7B-B2AFD8DD7946\83F8638B-8DCA-4152-9EDA-2CA8B33039B4\0\0\D")
But when I tried running it from command prompt as
powershell.exe C:\hyperv_disk_ops.ps1 -op 'getDiskAttachmentInfo' -vmid '{6612D0CB-BCC3-44D4-988B-526500578D54}' -disk_ids ("Microsoft:7B036CE0-5D67-46BA-AF7B-B2AFD8DD7946\83F8638B-8DCA-4152-9EDA-2CA8B33039B4\0\0\D")
it gave me an error
ERROR: Failed to find object of [Microsoft:7B036CE0-5D67-46BA-AF7BB2AFD8DD794683F8638B-8DCA-4152-9EDA-2CA8B33039B400D] disk which is associated with [{6612D0CB-BCC3-44D4-988B-526500578D54}] VM.
Both are exact same but why it is not running from Command Prompt?
Try running from the command prompt with double backslashes, like so:
powershell.exe C:\hyperv_disk_ops.ps1 -op 'getDiskAttachmentInfo' -vmid '{6612D0CB-BCC3-44D4-988B-526500578D54}' -disk_ids ("Microsoft:7B036CE0-5D67-46BA-AF7B-B2AFD8DD7946\\83F8638B-8DCA-4152-9EDA-2CA8B33039B4\\0\\0\\D")
It looks like, in the error you provided, all of the slashes are being omitted in the disk path.

CMN_1949 Error:[Pre/Post Session Command] in Informatica

I am getting the error:
CMN_1949 Error:[Pre/Post Session Command].The shell command failed with exit code=2.
The shell command contains only the code:
/bin/rm $INFA_HOME/server/infa_shared/Cache/*.idx*;
Can you help me?
Hope you are using the shell command in windows environment and since it could not execute your command . Try using MS-DOS command if in case you are using in the windows enviromnent . Use the command del inorder to delete the files . If you are using Unix environment kindly execute you command in the console and try , if you are getting any error .

Resources