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

Hi,
We use Visual Source Safe (in windows )as a configuration management tool apart from pvcs in Unix.
I have a perl script which generates reports based on many criterias ( eg. label name ) by reading the history details from VSS command line tools.
Before proceeding with the perl script, it is required to set up some environment variables in order to run the VSS Commands. So I have a DOS batch script which inturn calls the perl script which runs after setting the environment variable.

Well, that being said, these scripts have been running very well from the command line.
A new requirement is that to put all these functionality in a web-page. After I get the values from the user say database and labelname, I pass it to the batch using the system command in the cgi script.

The problem I face here is the batch file does not run as it does in the command line, and moreover, it does not take the values I pass from the html.
Here's the batch command.
REM %1 - is the Database path. REM %2 - Label name REM Setting the VSS Database to the path where the srcsafe.ini file is + located. set SSDIR=%1 vssreport.pl %1 %2

Replies are listed 'Best First'.
Re: CGI - Batch command
by tilly (Archbishop) on Oct 13, 2003 at 05:28 UTC
    Modify %ENV in the Perl script to set environment variables that will be seen in processes that it spawns.

      This solution would suffer, if multiple requests come in at the same time (assume the process runs on server). Well, you can carefully make the processes running in sequence, but this is not always desirable.

      Update:

      This post is actually not about tilly's reply, as his reply obviously provided a correct answer to the direct question itself, so don't mis-interprete this post.

        I don't understand what you are trying to refer to.

        The question was how to set environment variables when the Perl script was not being wrapped by a .bat file that set them. I answered that question.

        Larger questions of how to handle multiple requests at a time I can't answer without knowing a lot more about the environment that he is talking about.

        This post is actually not about tilly's reply, as his reply obviously provided a correct answer to the direct question itself, so don't mis-interprete this post.
        Then why did you reply to tilly's post?
Re: CGI - Batch command
by pg (Canon) on Oct 13, 2003 at 06:09 UTC

    Using environment variables to pass parameters was right, when you run your scripts in a batch mode as your company did before, but it is no longer a good solution, especially with data that is so dynamic (different from request to request).

    You can run scripts sequentially, but in a web application environment, response time to each user is usually quite sensitive. Believe me, very soon some user will start to yell at you.

    To be frank, whoever did the analysis and design missed something really important, and you are entitled to have more time to make things right with one punch.

    (I wish I didn't put that comment under tilly's post, as tilly was just trying to answer the direct question, and obviously his answer was correct. Well, that happens...)

Re: CGI - Batch command
by BrowserUk (Patriarch) on Oct 13, 2003 at 08:53 UTC

    Your post does not contain enough information to allow us to help you.

    ...these scripts have been running very well from the command line....

    ...the batch file does not run as it does in the command line...

    Archetypically, differences between the runtime behaviour of scripts running from the command line and the same scripts being run from a webserver are due to the fact that the userid used by the webserver does not have the same rights accorded it as the real user running it from the command line. VSS with try to authenticate the user running it, and unless you have given the userid that your websever runs as the appropriate authorisations to act as a proxy for everyone that will use the web-based version of the script, VSS will reject the attempts to obtain information, much less commit changes.

    ...it does not take the values I pass from the html...

    You don't show us how you are invoking the batch file from your CGi script, so our attempting to work out why the parameters are not making their way into the batch file correctly is impossible.

    As others have pointed out, it would be entirely possible to set the environment variables required by CSS directly within your perl script prior to invoking VSS as a child process and avoid one level of indirection, but unless it is possible (and safe!) to grant the webserver runtime account the appropriate authority to act as a proxy for the users invoking the CGI, you aren't going to achieve your goal.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    Hooray!

Re: CGI - Batch command
by rupesh (Hermit) on Oct 13, 2003 at 05:45 UTC

    You could take the inputs from the user and write them to a text file. And have another script (perl/batch) search for the text file every x seconds/minutes and generate the report from there...
    Just my 2 cents...


    @şÂ©ΪΪ SSζG