How to remove a file named "\" in clearcase vob directory? - clearcase

I have one file named "\" in a directory.
How does it got created, I have no idea.
And this file is creating problem with merge. I am not able to delete this file.
I tried option -- to delete this but nothing works
ct rmname -- \
It just ends with
>
Also the ct ls shows
\##/main/branch_457/1 Rule: .../branch_457/LATEST
Please suggest how can this type of file can be deleted.

If you are on Unix, you can try and follow the directives from "About special characters in file names on UNIX and Linux"
ct rmname '/'
Or try escaping the special character:
ct rmname \/
On Windows, the escape character is '^' (as mentioned in cleartool help page):
ct rmname ^/

Related

how can i use a wildcard in Cleartool?

I try to list my private files in Clearcase but i don't want to list all the files from all the folders, so i tried to use a wild card but without success.
I want only to list the private files in src folders.
The structure of the folders is like path1/to/src/ path2/to/src/
I tried in cleartool the cmd lsp -tag view_buildEnv .../.../src/...
but the wildcard .../.../src/... does not return any results.
In config spec i use the same command element .../.../src/... -none and it is working properly.
How could i make it with success also with cleartool ?
The main rules regarding wildcard (including ellipsis '...') are in "wildcards_ccase" (also detailed in "config_spec")
cleartool lsprivate works only in dynamic view.
The Windows examples that include wildcards or quoting are written for use in cleartool interactive mode. If you use cleartool single-command mode, you may need to change the wildcards and quoting to make your command interpreter process the command appropriately.
So try:
cd/d M:\myview\myvob
# or
cd /view/myview/vobs/myvob
cleartool lsp -tag view_buildEnv ".../src/"
# or
cleartool lsp -tag view_buildEnv ".../src/..."
(you should not have to specify anything after src/: lsprivate should list all private elements under src and its subfolders).
(plus: "In non-config-spec contexts, the ... pattern matches directory names only.")
If works well inside a vob, but might not work inside a view for multiple vobs.
In that case:
cd/d M:\
cleartool lsprivate | grep src
In batch file:
cmd /v /c "cd/d M:\; cleartool lsprivate | grep src"

Script for renameing special characters files and directories

I am looking for a script to rename files and directories that have special characters in them.
My files:
?rip?ev <- Directory
- Juhendid ?rip?evaks.doc <- Document
- ?rip?ev 2 <- Subdirectory
-- t?ts?.xml <- Subdirectory file
They need to be like this:
ripev <- Directory
- Juhendid ripevaks.doc <- Document
- ripev 2 <- Subdirectory
-- tts.xml <- Subdirectory file
I need to change the files and the folders so that the filetype stays the same as it is for example .doc and .xml wont be lost. Last time I did it with rename it lost every filetype and the files were moved to mother directory in this case ?rip?ev directory and subdirectories were empty. Everything was located under the mother directory /home/samba/.
So in this case I need just to rename the question mark in the file name and directory name, but not to move it anywhere else or lose any other character or the filetype. I have been looking around google for a answer but haven't found one. I know it can be done with find and rename, but haven't been able to over come the complexity of the script. Can anyone help me please?
You can just do something like this
find -name '*\?*' -exec bash -c 'echo mv -iv "$0" "${0//\?/}"' {} \;
Note the echo before the mv so you can see what it does before actually changing anything. Otherwise above:
searches for ? in the name (? is equivalent to a single char version of * so needs to be escaped)
executes a bash command passing the {} as the first argument (since there is no script name it's $0 instead of $1)
${0//\?/} performs parameter expansion in bash replacing all occurrences of ? with nothing.
Note also that file types do not depend on the name in linux, but this should not change any file extension unless they contain ?.
Also this will rename symlinks as well if they contain ? (not clear whether or not that was expected from question).
I usually do this kind of thing in Perl:
#!/usr/bin/perl
sub procdir {
chdir #_[0];
for (<*>) {
my $oldname = $_;
rename($oldname, $_) if s/\?//g;
procdir($_) if -d;
}
chdir "..";
}
procdir("top_directory");

Clearcase CASE INSENSITIVITY

I am trying to write a windows batch file to automate the checkout/check-in process for the ClearCasr tool but facing an issue with Case letters of the file name.
For example: if filename is "Hello_Working.txt" when I copied to my vob its becoming "hello_working.txt".
So when I do a checkout/check-in its prompting error as "Pathname not found".
I know MVFS "Clear Preserve" will solve the problem but if we change the setting other vobs which are running will affect, My admin suggested that your batch file script commands has to negotiate the cases of the file name. I am writing the command as below
Checkout:
ct co -nc H:\test1_view\test1_vob\Hello_working.txt
ct co -cfile "Comment"
Checkin:
ct ci -nc H:\test1_view\test1_vob\Hello_working.txt
ct ci -cfile "Comment"
Please let me know what needs to modify in the commands?
First, you don't have to co/ci -nc, and then co/ci -cfile "comment".
You can checkout with comment, and then ci -nc: a checkin without comment will use by default the comment given in the checkout step.
ct co -c "Comment" H:\test1_view\test1_vob\Hello_working.txt
ct ci -nc H:\test1_view\test1_vob\Hello_working.txt
Second, you can try checkin all the checked-out files, as in "Recursive checkin using Clearcase", which would make ClearCase find the right name (even when the filename is converted to lowercase in Windows dynamic view).
ct lsco -r -cvi -fmt "ci -nc \"%n\"\n" | ct
Even for one file, try the command ct lsco (cleartool lscheckout) in order to ask ClearCase for the right name.

How can I discover who's checked out a file in ClearCase?

I use ClearCase. How can I find out who's checked out a given file?
That kind of request is often prompted when you try to rmname (DEL) a file through the GUI.
If the file is checked-out in any other branch or any other view... the GUI will refuse to rmname the file!
To quickly see where the file is checked-out, try a
ct lsvtree myFile
and look (or grep) for "CHECKEDOUT" string.
You will se one or several line like:
path\to\myFile##\main\aBranch\CHECKEDOUT view "aViewTag"
But remember: you can also force a rmname through the CLI (Command-Line Interface) cleartool.
Assuming you are in the correct path of the file:
cleartool co -nc .
cleartool rmname -force myFile
cleartool ci -nc .
the -force option (not available through GUI) will allow you to rmname your file even if it is already checked-out in another view/branch.
Just do a cleartool lsco on the file element:
%cleartool lsco <element_name>

Recursive checkin using Clearcase

I want to check in a directory and all the sub-directories into the clear case.
Is there a specific command to achieve it?
Currently I am going into each directory and manually checking in each file.
I would recommend this question:
Now the problem is to checkin everything that has changed.
It is problematic since often not everything has changed, and ClearCase will trigger an error message when trying to check in an identical file. Meaning you will need 2 commands:
ct lsco -r -cvi -fmt "ci -nc \"%n\"\n" | ct
ct lsco -r -cvi -fmt "unco -rm %n\n" | ct
(with 'ct being 'cleartool' : type 'doskey ct=cleartool $*' on Windows to set that alias)
But if by "checkin" you mean:
"enter into source control for the first time"
"updating a large number of files which may have changed on an existing versionned directory"
I would recommend creating a dynamic view and clearfsimport your snapshot tree (with the new files) in the dynamic view.
See this question or this question.
the clearfsimport script is better equipped to import multiple times the same set of files, and automatically:
add new files,
make new version of existing files previously imported (but modified in the source set of files re-imported)
remove files already imported but no longer present in the source set of files.
make a clear log of all operations made during the import process.
:
clearfsimport -preview -rec -nset c:\sourceDir\* m:\MyView\MyVob\MyDestinationDirectory
did you used -recurse option in the clearfsimport command.
Example: clearfsimport -recurse source_dir .
This should help.
If you're using the Windows client, right-click on the parent folder, select Search, leave the file name field empty, click Search, select all the files in the result window (ctrl-A), right-click on them and select ClearCase -> Add to Source Control
If you are in windows you may try,
for /f "usebackq" %i in (`cleartool lsco -cview -me -r -s`) do cleartool ci -nc %i

Resources