Forum Discussion
TanyaYatskovska
Alumni
10 years agoHi Mortenb123,
Please see Dmitry's reply here. Let me quote it here:
To use quoted parameters, it is necessary, firstly, to add two quotation marks before the filename and after the last parameter, secondly, add the backslash symbol before and after the quoted parameter.
- mortenb12310 years agoContributor
Hi
I was unable to parse the regex correctly, so I changed the script just sending the phone-num and building the
regexp in the powershell program, then it works fine, but it means I cant use our generic readlog.ps script.
This is a generic parsing issue, since it did not work in cmd.exe either. PS is very convenient directly parsing any regexp.
PS C:\dist\ps> .\getotp.ps1 -server "test1-back-01.bptest.local" -phone "95505050" 7407
PS C:\dist\ps> .\readlog.ps1 -server "test1-back-01.bptest.local" -filter "OTP:\s\d{4}.*\+4795505050" 7407
in cmd.exe (same from cygwin shell):
c:\dist\ps>powershell C:\dist\ps\readlog.ps1 -server "test1-back-01.bptest.local" -filter "OTP:\\s\\d\{4\}.\*\\+4795505050"
At line:1 char:83
+ ... TP:\\s\\d\{4\}.\*\\+4795505050
+ ~
Missing property name after reference operator.var otp = powershell_GetOTP("test1-back-01.bptest.local", "95505050");
function powershell_GetOTP(servername, phone) { var script = "C:\\dist\\ps\\getotp.ps1"; var oShell = Sys.OleObject("WScript.Shell"); var ex = "powershell " + script + " -server \"" + servername + "\" -phone \"" + phone + "\""; Log.Message("executing:" + ex); var oExec = oShell.Exec(ex); oExec.StdIn.Close(); var strOutput = oExec.StdOut.ReadAll(); strOutput = aqString.Trim(strOutput, aqString.stAll); aqString.ListSeparator = "\r\n"; Log.Message(script + " returned:"); for (var i = 0; i < aqString.GetListLength(strOutput); i++) { Log.Message(aqString.GetListItem(strOutput, i)); } return strOutput; }