I have a script that reads the file path from the terminal. In the script, I checked if the file was in the P4 client's view. But I want to get rid of error messages. I am using p4 have. Redirecting the output of the run to the file or dumping the command output in some variable does not work. I see an error message in any-case.
You might like:
p4 -F %depotFile% have FILE
which will give you the depot file path if any, and no output at all if there isn't one.
The -F global option works with any command and allows you to override the standard message formatting. If you run p4 -e have
you'll see that when you have a file, you get a message with the %depotFile%
parameter, and if you don't, you get an error message with a different set of parameters. Overriding the formatting so that you only ever print the depotFile
will implicitly hide the error that you don't want to see.