Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Perl source safe get by label failure

by mgibian (Acolyte)
on Aug 22, 2003 at 23:40 UTC ( #285959=perlquestion: print w/replies, xml ) Need Help??

mgibian has asked for the wisdom of the Perl Monks concerning the following question:

I have a Perl script that I have been using to perform builds. This script uses the source safe command line to fetch files into the workspace before doing any building. It does very rigorous error checking to be sure no problems go unnoticed during the build process. The fetch portion of this script has worked well for a number of months.

Yesterday I implemented a new feature. The original script fetched the latest version of all files, performed the build, and then at the very end attached a build label to the latest version of all files (hoping there had been no divergence between the fetch and the label steps). My change is to very early in the build label the latest version of the files, and then fetch the labeled version of all files. This is failing, reporting an error 25600, "No such file or directory".

I tested one last variation... I took the current script and removed the label argument from the get command and this is now failing with the same 25600 error.

The command line(s) I am using are:
ss get $/project -R -I-Y -V"MYBUILDLABEL" ss get $/project -R -I-Y
Immediately prior to the get I do a ss Workfold to set the working folder to the desired target location, and that is succeeding with no problem. I have tried running the command line by hand in a shell window and THAT works without error.

My questions:

1 - Why is source safe reporting a non-zero error code? What error is it reporting?

2 - Is my script just being overly sensitive to warnings and such, or is there something here I can fix so that the "get" begins returning zero (again)?

Thanks very much for your help, Marc

Replies are listed 'Best First'.
Re: Perl source safe get by label failure
by particle (Vicar) on Aug 23, 2003 at 00:38 UTC

    a problem, but no code backing it up. that's a tough problem to solve. okay, without the code, i can give you help on debugging skills, because you're going to have to do them yourself. here's a partial list:

    • start small -- create the smallest script that can recreate the error.
    • read the error -- is there something in your environment that is preventing sourcesafe from getting a file? must a directory exist before a get to that directory succeeds?
    • add debugging -- print out in perl where you think it'll help. calling the system? print the line first.
    • add more debugging -- use sourcesafe's debugging features to see what it's doing.

    if you're still stumped, post the code here. some of us may have the (mis)forture of working with sourcesafe. but first, read jeffa's How (Not) To Ask A Question

    ~Particle *accelerates*

      The code I'm using comes in two parts. The general function for running source safe commands is:
      sub PerformSS { my $self = shift; my ($cmdArg) = @_; my $cmd = "ss " . $cmdArg; my $status = 0; if ($self->doSS) { $status = system("$cmd 1>>$errorfile 2>&1"); $self->checkError($status, "PerformSS $cmd failed $status $!"); $self->trace("--- completed $cmd ---\n"); } else { $self->trace("--- PerformSS did not $cmd ---\n"); } return $status; }

      The call I am trying to use to fetch by label from source safe is:
      $status = $self->PerformSS("get \$/project -R -I-Y -V\"$label\"" +);

      Note that checkError issues the error message and some addition supporting information if $status is not zero.

      On the other hand, the following code works just fine, which is why I had omitted the code in my original posting. The question I have is still... is there something special or different about how the fetch by label returns?
      $status = $self->PerformSS("get \$/project -R -I-Y");

        well, it's been a long time since i've used vss, i must admit. i've used pvcs vm for seven years, and am now implementing a merant dimensions infrastructure. i've been doing conversions from vss, but i don't know specifics on fetch by label.

        i can, however, help you modify your PerformSS subroutine to make it safer, and more robust. using IPC::Run will give you better control over std(in|out|err). passing system a list instead of a scalar will make the subroutine safer. here's an example:

        #!/usr/bin/perl use strict; use warnings; $|++; use IPC::Run qw/run timeout/; sub PerformSS { my( $self, @cmdArgs )= @_; my $status; $self->trace("--- PerformSS did not $cmd ---\n") unless $self->doSS; $status= run ( 'ss', @cmdArgs ) => \my( $in, $out, $err ) => timeout(10); $self->checkError($status => <<ERROR }; PerformSS $cmd failed: status: $status stdout: $out stderr: $err ERROR $self->trace("--- completed $cmd ---\n"); return ( $status, $out, $err ); } my @result= $self->PerformSS( 'get' => '$/project', '-R', '-I-Y', qq{-V"$label"} );


        • this code is untested, but it's passed my in-head compiler.
        • i've taken the liberty of formatting it the way i code, including fat commas, uncuddled braces, spacing, parameter passing methods, etc.
        • i've also changed both the input and output to the PerformSS method. it expects a list as input, to secure the system command (via IPC::Run,) and it returns a list including the status, stdout, and stderr for the caller to handle (if it needs it.)
        • this info is no longer written to an errorfile--an errorfile that was already a package global, anyway, so there's one less use of a global var, which is considered (by some) a Good Thing, especially in OO code like yours.

        your mileage may vary, but IPC::Run is a powerful module that i use in all my automation when i'm working beyone the capabilities of system and qx{}.

        to diagnose the vss errors, i suggest you create a small script (like this one) that uses IPC::Run to test both methods, and inspect the results carefully. you'll have to find a vss forum for more expert help. perhaps has a forum for that?

        ~Particle *accelerates*

Re: Perl source safe get by label failure
by gellyfish (Monsignor) on Aug 23, 2003 at 10:41 UTC

    How are you running the source dafe commands? Of course without seeing your code I can't tell for sure, but it is possible you are attempting to interpolate Perl's $/ builtin variable unintentionally


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://285959]
Approved by ybiC
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2022-05-26 05:42 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (93 votes). Check out past polls.