0

I am experiencing the following difference in using a pipe and using a file input when updating a perforce job: When doing the update (in a windows cmd shell) as follows:

(echo job: job00101&echo.status: open&echo.description: One line only)|p4.exe -p myServer:1234 -u myUser job -f -i 

the description in the job has an additional blank at the end, and an additional empty line. (Visible, when editing the job with P4V)

When I try the same using two commands and an intermediate file

(echo job: job00101&echo.status: open&echo.description: One line only) >test.txt
p4.exe -p myServer:1234 -u myUser job -f -i <test.txt

the description consists of exactly one line without a trailing blank. That is what I would also have expected when using the pipe.

What I need is a one line command without the need of an intermediate file. And I do not understand why the pipe does not work the same as the file output and input.

Xavier T.
  • 40,509
  • 10
  • 68
  • 97
user2808624
  • 2,502
  • 14
  • 28
  • Possible duplicate of [Windows cmd echo / pipe is adding extra space at the end - how to trim it?](https://stackoverflow.com/questions/29747539/windows-cmd-echo-pipe-is-adding-extra-space-at-the-end-how-to-trim-it) – aschipfl Feb 20 '19 at 15:55

1 Answers1

2

I think cmdline redirection is seriously broken in DOS batch. Is Powershell an option at all?

"job: job00101`nstatus: open`ndescription: One line only" | p4.exe -p myServer:1234 -u myUser job -f -i

As an alternative, if you must be running from within DOS batch, you can use this:

powershell -Command "\"job: job00101`nstatus: open`ndescription: One line only\" | p4.exe -p myServer:1234 -u myUser job -f -i"
sferencik
  • 3,144
  • 1
  • 24
  • 36
  • Great. That made the difference. I still have the linefeed, but the trailing space is gone, and that was causing the problems in my case. – user2808624 Nov 04 '15 at 06:50