cancel
Showing results for 
Search instead for 
Did you mean: 

sourcing script help

SOLVED
Go to solution
Padma Asrani
Honored Contributor

sourcing script help

Hello Friends

I am facing one problem with the sourcing script. I don't know in past it used to run. I am facing a problem wherein it is not able to set the path for cleartool.exe

We have following command to find the path of cleartool.exe

CLEARTOOL=`type cleartool | sed -e 's%\\\\%/%g' -e 's/.* //' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`

But on my system the output is

files/rational/clearcase/bin/cleartool.exe: not found

Instead of
C:\Program Files\Rational\ClearCase\bin\

Can anybody give me the idea how to fix it.

Regards
Padma
6 REPLIES
Jonathan Fife
Honored Contributor

Re: sourcing script help

Are you using cygwin or something?

What are the contents of the "cleartool" file you are sending to sed? The sed statement is going to replace any double \\s with a single /, and remove any text up to and including the first space.
Decay is inherent in all compounded things. Strive on with diligence
Jonathan Fife
Honored Contributor

Re: sourcing script help

Edit above:

Oh, I see you aren't using the windows type command, but the shell builtin.

I'm not sure what you are doing in that case...taking the path to your current cleartool executable and reformatting it for what? What does "type cleartool" give you? What does "echo $CLEARTOOL" give you after running the command? What do you want it to give you?
Decay is inherent in all compounded things. Strive on with diligence
Padma Asrani
Honored Contributor

Re: sourcing script help

Hi

Thanks for the response. When I run
type cleartool it give following output

cleartool is C:/Program Files/Rational/ClearCase/bin/cleartool.exe
but when it pipes it with sed as below within the script then it gives the following output

`type cleartool | sed -e 's%\\\\%/%g' -e 's/.* //' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`

files/rational/clearcase/bin/cleartool.exe: not found

It should set the path to cleartool as
C:/Program Files/Rational/ClearCase/bin/cleartool.exe

Regards
PAdma
Jonathan Fife
Honored Contributor

Re: sourcing script help

Well, unless I'm missing something:
CLEARTOOL=`type cleartool`
Decay is inherent in all compounded things. Strive on with diligence
Dennis Handly
Acclaimed Contributor
Solution

Re: sourcing script help

(Your example is not for HP-UX but evil windows with embedded spaces.)

If you have Unix, you can use dirname(1):
$ CLEARTOOL=$(dirname "$(type cleartool)")

Your above sed and tr commands are useless. You don't want to downshift. You don't want to delete everything before the first space. Nor do you want to change \\ to /.

Using this sed may help:
sed -e 's/\(.*\\\).*$/\1/'
It should remove everything after the last "\".
Peter Nikitka
Honored Contributor

Re: sourcing script help

Hi,

one hint is the space in the pathname, but the major problem is: you are on windows :-)

Not knowing, which UNIX-tools are available, I think, you should have 'tr' as well, when a 'sed' is in sight.
On a MKS-ksh-Shell this starts the cleartool command for me:
$ ct=`whence cleartool | tr '\\' /`
$ print $ct
C:/Program Files/Rational/Clearcase/bin/cleartool.EXE
$ "$ct"

mfG Peter

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"