Command Line Arguments

This topic contains 11 replies, has 3 voices, and was last updated by Profile photo of Richard Diphoorn Richard Diphoorn 6 months, 3 weeks ago.

  • Author
    Posts
  • #39166
    Profile photo of Barry Walledge
    Barry Walledge
    Participant

    Morning Guys

    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.txt To '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.txt The issue seems to be the < I've tried multiple ways but with no joy, can anyone help me please? Many thanks Barry

  • #39169
    Profile photo of Richard Diphoorn
    Richard Diphoorn
    Participant

    Try this:

    & 'C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpncli.exe' --% –s < C:\Temp\Connect.txt
    
  • #39171
    Profile photo of Barry Walledge
    Barry Walledge
    Participant

    Hi Richard

    Thanks for your reply. I did try that before and it fails with

    The '<' operator is reserved for future use. Thanks Barry

  • #39172
    Profile photo of Richard Diphoorn
    Richard Diphoorn
    Participant

    That is strange. PowerShell should ignore what is coming after the –% and pass it to the referenced executable. You're using a double dash?

  • #39174
    Profile photo of Barry Walledge
    Barry Walledge
    Participant

    Yep def, just doubled checked.

    Thanks

  • #39178
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    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'
    
  • #39179
    Profile photo of Barry Walledge
    Barry Walledge
    Participant

    Hi Dave

    That works perfectly!

    Many thanks for your help

    Barry

  • #39181
    Profile photo of Richard Diphoorn
    Richard Diphoorn
    Participant

    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?

  • #39182
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    I thought so as well, but maybe the pipe and/or redirection operators still take precedence. Haven't played with that much.

  • #39184
    Profile photo of Richard Diphoorn
    Richard Diphoorn
    Participant

    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.txt
    
  • #39185
    Profile photo of Barry Walledge
    Barry Walledge
    Participant

    Hi Richard

    Tried the suggested change and back to the first error:

    The '<' operator is reserved for future use. Thanks Barry

  • #39187
    Profile photo of Richard Diphoorn
    Richard Diphoorn
    Participant

    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.