- May 16, 2016 at 10:47 pm #39166
Wondered if you could help. I'm trying to send the following command line arguments to the Cisco Anywhere connect VPN command line without much luck.
I need to pass:
–s < C:\Temp\Connect.txtTo'C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpncli.exe'So the line should like:'C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpncli.exe' –s < C:\Temp\Connect.txtThe issue seems to be the < I've tried multiple ways but with no joy, can anyone help me please?Many thanksBarryMay 17, 2016 at 2:05 am #39169
& 'C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpncli.exe' --% –s < C:\Temp\Connect.txtMay 17, 2016 at 2:24 am #39171
Thanks for your reply. I did try that before and it fails with
The '<' operator is reserved for future use.ThanksBarryMay 17, 2016 at 2:27 am #39172
That is strange. PowerShell should ignore what is coming after the –% and pass it to the referenced executable. You're using a double dash?May 17, 2016 at 2:31 am #39174
Yep def, just doubled checked.
ThanksMay 17, 2016 at 4:05 am #39178
That symbol isn't actually passed to the executable. Whatever documentation you're reading probably assumes that you're running it from cmd.exe, where the < operator is input redirection. Without knowing how their app works, the simplest thing to do in PowerShell is probably just to wrap the call in a call to cmd.exe:
cmd.exe /c '"C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpncli.exe" –s < C:\Temp\Connect.txt'May 17, 2016 at 4:22 am #39179
That works perfectly!
Many thanks for your help
BarryMay 17, 2016 at 4:24 am #39181
Dave, do you know why –% doesn't work in this situation? My impression always was that PowerShell would pass whatever you typed to the executable?May 17, 2016 at 4:26 am #39182
I thought so as well, but maybe the pipe and/or redirection operators still take precedence. Haven't played with that much.May 17, 2016 at 4:30 am #39184
Look like a little bug then in the –% escape character. I wonder if you could escape it. But putting it in single quotes is much simpler, as you proposed. 🙂
@Barry: would you be so nice to try this, to satisfy my curiosity? 🙂 :
& 'C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpncli.exe' --% –s `< C:\Temp\Connect.txtMay 17, 2016 at 4:36 am #39185
Tried the suggested change and back to the first error:
The '<' operator is reserved for future use.ThanksBarryMay 17, 2016 at 4:38 am #39187
Thanks Barry! Seems indeed that redirection characters cannot be parsed with the –% escape character as a string. Seems a bug to me.
You must be logged in to reply to this topic.