deostroll
(arun jayapal)
March 30, 2020, 5:52am
1
I am trying to run a powershell command to get the system date. In a windows command line you type this:
powershell -command (date).ToString('yyyyMMddhhmmss')
It outputs the current time in the required format. However stashing this into ruby code filter after escaping the single-quote causes error.
ruby {
code => 'event.set("ctime", `powershell -command (date).ToString(\'yyyyMMddhhss\')`)'
}
I get the following error:
deostroll
(arun jayapal)
March 31, 2020, 6:24am
2
I guess this is a problem with ruby version used by jruby (as of v7.6.1)
However, the following workaround might help:
Make a script (powershell as in this case) to output the system time in the required format
Utilize script from within the ruby filter
ruby {
code => 'event.set("ctime", `powershell d:/code/ps1/misc/time.ps1`)'
}
system
(system)
Closed
April 28, 2020, 6:24am
3
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.