Why can't Perl find my file that is in ClearCase? - perl

This piece of Perl is telling me that a file in ClearCase doesn't exist when it does;
$x = "PATH/TO/FILE"
if (-e $x) {
print "This file exists on the file system";
} else {
print "I can't see this file";
}
Has anyone seen this before?
Some files return fine. Got me stumped.
Clearcase view is dynamic, hosted on unix.
This piece of code is returning that a file exists and another doesn't when they are in the same folder on the same view.

Clearcase stores its 'files' as directories
What Aric is trying to tell you is that ClearCase uses extended path names, "extended" because it extends the file name with version path.
So in a dynamic view, any file can be described to reveal its versioning path:
$ ct ls
myFile
$ ct descr -l myFile
myFile##/main/3
In a dynamic view, you can actually explore the versions of a file (hence the "file as directories") part
$ cd myFile##
$ ls
main
$ cd main
$ ls
3
$ cat 3
... // content of third version of myFile
Now, if ClearQuest (the issue tracking system) were used here, it would reference activities (change set of file set) of ClearCase.
But with ClearCase, a version of a file (referenced by ClearQuest or obtained through another mean) can very well has been deleted in the dynamic view ("rmnamed" actually).
Meaning a file may be referenced by ClearQuest or by some ClearCase activity, but not be visible directly with ClearCase in the dynamic view.
However, its extended path name would still be accessible in that same dynamic view.

Clearcase stores its 'files' as directories. You can cd into an file and get into the actual directory that it's using to store all of the revisions of a file; While the OS hooks usually work, perhaps this is causing Perl to not recognize some of the files.

Related

vscode: how to setup a workspace by providing a master file list?

Some IDEs support a feature usually called "master filelist", that the user provides a simple text file containing all files for a project, thus the IDE only parses the listed files.
Is it possible with vscode workspace? Note that I am aware of the "Exclude" feature of vscode, but it is not convenient for my use case.
Thanks.
After trying many methods (all in vain), I came up with the following workaround: make symlinks to all files in the master filelist.
Suppose that the files in the filelist (${ABS_INCLUDE}) are with absolute pathes, and suppose they share a root directory (which can be always true), then first create a dedicated root directory (SYM_ROOT_DIR) for vscode workspace, and then create symlinks for each files under the new root directory, e.g.,
mkdir -p ${SYM_ROOT_DIR}
while IFS= read -r line
do
OLD_DIR=$(dirname "$line")
BASENAME=$(basename "$line")
SYM_DIR=$(echo "${OLD_DIR}" | sed "s#${ABS_ROOT_DIR}#${SYM_ROOT_DIR}#")
mkdir -p ${SYM_DIR}
ln -s ${line} ${SYM_DIR}/${BASENAME}
done < ${ABS_INCLUDE}

rename command doesn't rename

This should work on my CentOS 6.6 but somehow the file name is not changed. What am I missing here?
rename -f 's/silly//' sillytest.zi
This should rename sillytest.zi to test.zi but the name is not changed. Of course I can use mv command but I want to apply to many files and patterns.
There are two different rename utilities commonly used on GNU/Linux systems.
util-linux version
On Red Hat-based systems (such as CentOS), rename is a compiled executable provided by the util-linux package. It’s a simple program with very simple usage (from the relevant man page):
rename from to file...
rename will rename the specified files by replacing the first occurrence of from in their name by to.
Newer versions also support a useful -v, --verbose option.
NB: If a file already exists whose name coincides with the new name of the file being renamed, then this rename command will silently (without warning) over-write the pre-existing file.
Example
Fix the extension of HTML files so that all .htm files have a four-letter .html suffix:
rename .htm .html *.htm
Example from question
To rename sillytest.zi to test.zi, replace silly with an empty string:
rename silly '' sillytest.zi
Perl version
On Debian-based systems ,rename is a Perl script which is much more capable
as you get the benefit of Perl’s rich set of regular expressions.
Its usage is (from its man page):
rename [ -v ] [ -n ] [ -f ] perlexpr [ files ]
rename renames the filenames supplied according to the rule specified as the first argument.
This rename command also includes a -v, --verbose option. Equally useful is its -n, --no-act which can be used as a dry-run to see which files would be renamed. Also, it won’t over-write pre-existing files unless the -f, --force option is used.
Example
Fix the extension of HTML files:
rename s/\.htm$/.html/ *.htm

Find unused resource files (.jsp, .xhtml, images) in Eclipse

I'm developing a large web application in Eclipse and some of the resources (I'm talking about files, NOT code) are getting deprecated, however, I don't know which are and I'm including them in my ending war file.
I know Eclipse recognizes file paths into its directory because I can access the link to an image or other page while I'm editing one of my xhtml pages (using Control). But is there a way to localize the unused resources in order to remove them?
Following these 3 steps would work for sites with a relatively finite number of dynamic pages:
Install your site on a filesystem mount'ed with atime (access time).
Try harvesting the whole site with wget.
Use find to see which files were not accessed recently.
Done.
As I know Eclipse doesn't have this (need this too).
I'm using grep in conjuction with bash scripting - shell script takes files in my resource folder, put filenames in list, greping throught source code for every record in the list and if grep find it it is removed.
At the end list is printed on console - just unused resources retain in the list.
UCDetector might be your best bet, specifically, the custom marker aspects of this tool.
In Eclipse I have not found a way. I have used the following shell command script.
Find .ftl template files which are NOT referenced in .java files
cd myfolder
find . -name "*.ftl" -printf "%f\n" |while read fname; do grep --include \*.java -rl "$fname" . > /dev/null || echo "${fname} not referenced" ; done;
or
Find all .ftl template files which are NOT referenced in .java, .ftl, .inc files
cd myfolder
find . -name "*.ftl" -printf "%f\n" |while read fname; do grep --include \*.java --include \*.ftl --include \*.inc -rl "$fname" . > /dev/null || echo "${fname} not referenced" ; done;
Note: on MacOSX you can use gfind instead of find in case -printf is not working.
Example output
productIndex2.ftl not referenced
showTestpage.ftl not referenced

How to ask ClearCase to identify and make nice with new files?

I have a whole big bunch of new files I've recently dropped (via robocopy) into a folder tree. How can I ask ClearCase UCM to identify those files and get them placed under version control?
One easy way is to use clearfsimport in order to do a (recursive) import of a full directory content.
See "How can I use ClearCase to “add to source control …” recursively?".
It does work for ClearCase UCM view as well as base ClearCase view.
You only have to set an activity on the view you are using for the import before executing the clearfsimport.
That is easier than copying those file directly in the ClearCase destination view, and trying to detect those private (i.e. "not yet versionned") files.
Ah, turned out someone had already made such a post on an internal blog. Who knew!
I took that and then expanded it
for /f %1 in ('cleartool ls -r -s -nxname -view_only ^| grep -e ^\.\\SRC_ ^| grep -e vcproj$') do #cleardlg -addtosrc -nc "%1"
(Yeah, I've got some unix tools installed, grep and the like).
Looks for all vcproj files in a directory that starts with .\SRC_.

How to trace which enviroment variable is coming from

My colleague has created an JAVA_HOME variable somewhere but he could not remember.
I have check /etc/profile, /etc/bashrc, /root/.bash_profile, /root/.bashrc. All these files does not have a line to set JAVA_HOME, but it still keep coming back with old values.
So, is there a way to find out where is it coming from?
Here's one crude but effective way:
cd /
grep -r "JAVA_HOME" .
This will recursively search all subdirectories under the starting point (the UNIX root directory, in this example) for any file containing the string 'JAVA_HOME'.
You can use grep -r --include="*.ext" "JAVA_HOME" . if you want to restrict your searches to files having the extension .ext.