Pass Hostname to a batch script


From a triggered alert, I'm running a batch script and trying to pass the host name using this parameter %event_1.HostName% as the variable.  This worked fine using Intrust version 11.1 but, it doesn't seem to work for version 11.4.1.  Is there a different variable that I can use for hostname?  The application that is running the batch file is using %1 within the script and is not seeing the parameter that is being passed.

Parents
  • Hello Igor,

    Sorry, I mistyped the variable on my post but, I do have the correct field listed below.  The batch file that I'm trying to pass this variable to uses %1 within the batch file... The batch file looks like this.   echo %1 > logname.txt. Does Intrust allow me to echo a string into a file using ">"?

  • Hi Eddie,

    Yes, sure.

    Response Action type = Execute Command

    Application = cmd.exe

    Parameters = /C C:\Dumps\redir.cmd %event_1._HostName%

    Where C:\Dumps\redir.cmd should be changed to your script.

    Please transfer the "verified answer" mark here Stuck out tongue

  • Hello Igor,

    I attached a screen shot of the attempt you replied to me to my open Service Request # 4747601

    On the screen shot I attached, the red arrows is related to the execute command I'm trying to setup to echo the hostname into a file and the green arrow is the task to gather logs from the file where I the hostname should be in.

    As you can see on the status section, no objects were found because nothing was found in the computer list file.

  • I also want to add, that I just ran a test and replaced the variable %event_1._HostName% with a server name and the .cmd  script did not pick up the server name argument to write to the text file.

  • Hi Eddie,

    My guess is that you mixed up the execution sides. InTrust is an agent-server system, and the rule and all the response actions are matched on agent side by default. I think "D:\InTrust\Scripts" and "D:\InTrust\TextFiles" are on server side and you expect them to work on server side. Luckily we can easily switch the response action to server. For that go to the Execute Command response action and on General tab switch execution to server.

    Another side note. You use > to write to the file, but if the rule match on several agents rather simultaneously, you might miss a host to collect from. I would recomment using >> to appent the fiile, and another task to clean-up the file on schedule.

Reply
  • Hi Eddie,

    My guess is that you mixed up the execution sides. InTrust is an agent-server system, and the rule and all the response actions are matched on agent side by default. I think "D:\InTrust\Scripts" and "D:\InTrust\TextFiles" are on server side and you expect them to work on server side. Luckily we can easily switch the response action to server. For that go to the Execute Command response action and on General tab switch execution to server.

    Another side note. You use > to write to the file, but if the rule match on several agents rather simultaneously, you might miss a host to collect from. I would recomment using >> to appent the fiile, and another task to clean-up the file on schedule.

Children