Therefore, I spent some time getting it to work in various scripts in bash, and although it is not specific to dotnet, I decided to share my results, since these concepts are universal.
You have two options for receiving files from a remote computer:
- Check and synchronize the display of the workspace using the temporary client / workspace, as Sam Stafford wrote in his answer . Here's what in bash with comments:
# p4 uses this global variable as client/workspace name by default.
- Use
p4 print to print the contents of each file as suggested by jhwist wrote , so you don’t have to define a workspace at all. The disadvantage is that you have to process each file separately and create any directories yourself.
p4RemoteRoot="//depot/dir1" # First, list files and strip output to file path # because 'p4 files' prints something like this: # //depot/dir1/file1.txt#1 - add change 43444817 (text) # //depot/dir1/folder/file2.txt#11 - edit change 43783713 (text) files="$(p4 files $p4RemoteRoot/... | sed 's/\(.*\)#.*/\1/')" for wsFile in $files; do # construct the local path from the remote one targetFile="$localPath/${wsFile#$p4RemoteRoot/}" # create the parent dir if it does not exist. p4 files does not list directories mkdir -p $(dirname $targetFile) # print the file content from remote and write that to the local file. p4 print -q $wsFile > $targetFile done
Note: I could not find any documentation for the --field argument, but it looks like you can use all of the "Form Fields" as stated in the documentation: https://www.perforce.com/manuals/v18.2/cmdref /Content/CmdRef/p4_client.html
source share