1

I ran the following winrs command using backtick (``) in perl script,

$result = `winrs -r:<system_name> d:\tmp\transfer_remove_file.bat`

winrs windows is hangs after executing and it didn't return the output, after I close the window, I am able to see the output of winrs command.

As I need to capture the winrs result, I am using backtick, if I use system() call, it is not hanging, but i am not able to capture the output.

I can redirect the output of winrs to a file and use system(), like as follow,

system( winrs -r:<system_name> d:\tmp\transfer_remove_file.bat >> testlog.txt )

but when using multiple winrs in the same script and doing the redirect to same file, getting the following error

the process cannot access the file because it is being used by another process.

Please help me to address this issue

melpomene
  • 84,125
  • 8
  • 85
  • 148
Ganeshwari
  • 13
  • 3
  • You have to escape the backslashes or use forward slashes. That means, replace the path either with "d:\\tmp\\transfer_remove_file.bat" or "d:/tmp/transfer_remove_file.bat". You probably have more bugs in your script but that will maybe bring you one step forward. – Guido Flohr Oct 06 '17 at 20:47
  • try run it as open(my $ph, "comand |"); https://perldoc.perl.org/perlipc.html. then select it by IO::Select and read it in a loop when it possible. – ilux Oct 07 '17 at 11:39
  • I am getting this error message, after using open with pipe and IO::Select "Winrs error:The pipe is being closed." – Ganeshwari Oct 11 '17 at 11:54

0 Answers0