0

I'm running jf.exe from PowerShell and its not working and throwing below error, have tried multiple ways (commented in the code) below nothing seem to work, the EXE"jf.exe: exists in the exact same location

   At C:\Program Files\actions-runner\_work\_temp\62db6136-4c6a-45db-9d86-865e38a2797b.ps1:4 char:33
 + "E:\Program Files\JFrog\jf.exe" rt ping
 +                                 ~~
Unexpected token 'rt' in expression or statement.
+ CategoryInfo          : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : UnexpectedToken

  Error: Process completed with exit code 1.




  name: Build
  on:
   workflow_dispatch

 jobs:
  build:
   name: Build
   runs-on: [self-hosted,X64,dev,Windows]
   steps:
    - uses: actions/checkout@v2
    - run: |
      # Ping the server
      #$cmd = "E:\Program Files\JFrog\jf.exe rt ping"
      #Invoke-Expression -Command "& 'E:\Program Files\JFrog\jf.exe' rt ping"
      #Invoke-Expression -Command "& '$cmd'"
      [string]$JFExe = "E:\Program Files\JFrog\jf.exe"
      [Array]$arguments = "rt", "ping"
      & $JFExe $arguments
    
TylerH
  • 20,799
  • 66
  • 75
  • 101
wehelpdox
  • 339
  • 6
  • 16
  • 2
    The error seems pretty obvious - `E:\Program Files\JFrog\jf.exe` is not accessible on the machine running the github action... – Mathias R. Jessen Mar 11 '22 at 15:22
  • As an aside: [`Invoke-Expression` (`iex`) should generally be avoided](https://stackoverflow.com/a/51252636/45375); definitely [don't use it to invoke an external program or PowerShell script](https://stackoverflow.com/a/57966347/45375). – mklement0 Mar 11 '22 at 16:01
  • 1
    @MathiasR.Jessen it exists on the machine, the same command if i copy and run it from powershell command line it works – wehelpdox Mar 11 '22 at 21:01
  • @mklement0, whats the alternative way ? – wehelpdox Mar 11 '22 at 21:03
  • @wehelpdox, follow the second link in my previous comment. However, your own attempt, `& $JFExe $arguments`, should work. – mklement0 Mar 11 '22 at 23:08
  • @mklement0 At C:\Program Files\actions-runner\_work\_temp\62db6136-4c6a-45db-9d86-865e38a2797b.ps1:4 char:33 + "E:\Program Files\JFrog\jf.exe" rt ping + ~~ Unexpected token 'rt' in expression or statement. + CategoryInfo : ParserError: (:) [], ParseException + FullyQualifiedErrorId : UnexpectedToken Error: Process completed with exit code 1. – wehelpdox Mar 12 '22 at 01:21
  • @wehelpdox, that suggests the absence of the required call operator, `&`, which is required for syntactical reason whenever a command name or path is _quoted_ and/or contains _variable references_ or subexpressions - see [this answer](https://stackoverflow.com/a/57678081/45375). In other words: your symptom suggests that you did _not_ use `& $JFExe $arguments` for invocation. – mklement0 Mar 12 '22 at 02:50

0 Answers0