Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Help setting a variable in a Batch that is copied to a text file  (Read 3183 times)

0 Members and 1 Guest are viewing this topic.

lostdude

  • Guest
Hello,

I need to set a variable in a batch file that is then copied into a text file. I know how to set and use variables within a batch but don’t know how to pass the variable to the text file. Any help would be appreciated. Thanks

WillyW



    Specialist
  • Thanked: 29
  • Experience: Experienced
  • OS: Windows XP
Re: Help setting a variable in a Batch that is copied to a text file
« Reply #1 on: May 10, 2007, 05:11:17 PM »
Hello,

I need to set a variable in a batch file that is then copied into a text file. I know how to set and use variables within a batch but don’t know how to pass the variable to the text file. Any help would be appreciated. Thanks


1.)  Can you show us some of your code, so we can get a feel for what you 
      are trying to do?


2.)   In the meantime,  what happens if you do something like this in your 
        batch file? :
        echo  %variable_name_here%   >   filename.txt

       or

        echo   %variable_name_here%  >> filename.txt



.



GuruGary



    Adviser
    Re: Help setting a variable in a Batch that is copied to a text file
    « Reply #2 on: May 10, 2007, 07:21:36 PM »
    Is this a homework assignment?  And what operating system are you using?

    lostdude

    • Guest
    Re: Help setting a variable in a Batch that is copied to a text file
    « Reply #3 on: May 11, 2007, 08:21:38 AM »
    Not A homework assignment I just would like some help. Let give more details.
    Hardware and operating system:
    AMD Opteron 848 server running Windows Server 2003 SP1.
    I need to set a variable in the batch so the users can change them in one place each month. The essmsh command starts the Essbase interface in interactive mode. The variables I'm trying to set need to update in CopySPS.txt prior to the essmsh line running. In CopySPS.txt they are set again so that Essbase can save them as user defined variables which are then used in calculation scripts.


    ***************BATCH SCRIPT**************************************
    Set clearscen = Actual\\Forecast_2007
    Set ClearStart = May

    essmsh E:\Hyperion\HypData\EssAdmin\SPS\CopySPS.txt
    *****************************************************************

    ***************************COpySPS.txt******************************
    /* pdate the specified variable value. !!(SV_OptA_1, SV_OptA_2, SV_OptA_3, No Change)!!*/
    alter database GL.GL set variable "clearscen" "Actual\\Forecast_2007";
    alter database GL.GL set variable "clearstart" "May";
    ********************************************************************




    GuruGary



      Adviser
      Re: Help setting a variable in a Batch that is copied to a text file
      « Reply #4 on: May 11, 2007, 09:26:40 AM »
      So you want to be able to save CLEARSCEN and SLEARSTART to a file and be able to change them in the batch file?

      You can save them to a file like:
      Code: [Select]
      Set clearscen=Actual\\Forecast_2007
      Set ClearStart=May

      echo %clearscen% > E:\clearscen
      echo %ClearStart% > E:\ClearStart

      You read them in like:
      Code: [Select]
      set /p clearscen=<E:\clearscen
      set /p ClearStart=<E:\ClearStart

      echo clearscen=%clearscen%
      echo ClearStart=%ClearStart%

      Obviously, you don't want the static SET in your batch file if you are reading the variables from a file, you just need something to set them with the first time.  Is that what you were looking for?

      lostdude

      • Guest
      Re: Help setting a variable in a Batch that is copied to a text file
      « Reply #5 on: May 11, 2007, 12:10:09 PM »
      Hey GuruGary,

      Correct I need to be able to set and change variable in the batch script and have variable change in the text file. The text file actually contains the instructions that Essbase will use. So in sequence of events it should be the following.
      1 Set variable in batch and save batch
      2 Kick of batch
      3 Batch sends variable to a specific place in the text file
      4 Batch calls text file using essmsh command which reads text file with Essbase command containing   changed statement.
      5 Essbase executes instructions in text file
      Thanks

      GuruGary



        Adviser
        Re: Help setting a variable in a Batch that is copied to a text file
        « Reply #6 on: May 11, 2007, 11:04:46 PM »
        1 Set variable in batch and save batch
        Set what variable, and where do you get the information on what the variable is, and what the value is?  And what do you mean "save batch"?  The batch file should be static.  Please explain.