#! /usr/bin/perl # ## NAME: searchclient.pl ## DESC: Does a search using client syntax of current workspace # Example: where the search string is 'foo' # # p4 files //clientname/...foo... # # 1) In P4V, Click on Tools -> Manage Custom Tools. Click the 'New' # button and select 'Tool'. # # 2) Fill in the 'Name' field to identify the operation. For example: # # Search Client # # 3) In P4V, under 'Application', enter in the path where the # script is located. Such as: C:\customtools\searchclient.pl # # 4) For the 'Arguments' enter these four *in this order*: # # $u $p $c $D # # They correspond with the four arguments passed into the script: # current user, current port, current client, search string. # # 5) In P4V: Click the check-boxes for 'Add to applicable context menus'; # and 'Run tool in terminal window'. # # Also, click the check-boxes for 'Prompt user for arguments' and # under 'Description' for the prompt you can enter something like: # # Enter file specification pattern - wild cards acceptable - and click OK # # 6) Click the 'OK' button and save your changes. # $user = shift ARGV; #The current user. $server = shift ARGV; #ip_address:port of your Perforce server. $client = shift ARGV; #The current workspace. $srchstring = shift ARGV; #The user entered search string $p4 = "p4"; #Absolute path to the p4 cli program. $cmd = "$p4 -u $user -p $server files //$client/...$srchstring... |"; open RESULTS, $cmd or die "Cannot run file search command.\n\n"; $count = 0; print "$cmd\n"; print "...\n"; while () { chomp; print "$_\n"; $count++; } if($count ne 0) { print "\nFile search information complete.\n"; } if($count eq 0) { print "\nNo results found.\n"; } exit 0;