Harvest

 View Only
  • 1.  hexecp and System Variables - File name / Item name only

    Posted Feb 25, 2021 05:03 AM
    Hi,

    I'm running some scripts on a Windows agent. I would like to send the file name / item name as arguments, but I can currently only use the [version] system variable which includes the complete path, item names and version numbers if applicable. I there a way to get hold of just the item name?

    Thank you in advance


  • 2.  RE: hexecp and System Variables - File name / Item name only

    Broadcom Employee
    Posted Feb 26, 2021 03:29 AM
    Hello Jarus,

    We may need to write some extra scripting to get the file name.

    Can you check if the following works ?

    echo off

    echo 1: %1
    echo 2: %~nx1

    SET data=%~nx1
    FOR /f "tokens=1,2 delims=;" %%a IN ("%data%") do echo %%a&

    Program : cmd /c c:\test\build.bat ["version"]

    Sample Output :
    ============ 
    ---------- Begin <TestUDP> Process ---------------
    C:\Program Files\CA\SCM>echo off
    1: "\hmvrepo\JHSDKSampleProject .har;1"
    2: JHSDKSampleProject .har;1
    JHSDKSampleProject .har
    I00060052: TestUDP execution was successful.
    ---------- End <TestUDP> Process ---------------

    Thanks,
    Sridhar


  • 3.  RE: hexecp and System Variables - File name / Item name only

    Posted Mar 03, 2021 06:33 AM
    Hi Sridhar,

    Thank you for the suggested solution. That works, but unfortunately we already have multiple scripts set up that accept a file name and extension as only parameter and I was hoping we wouldn't have to change those.

    If need be, we'll have to, but I would think this should be a standard variable available for scripting.

    Kind regards,
    Jarus