Re: [go-nuts] Trying to call powershell script from Go

2020-11-01 Thread Uzair Ally
Hi Kurtis, The issue on my end was the same, I had to bypass execution policy for powershell and change script.ps1 to \\script.ps1. Thanks for your help with this, much appreciated! On Thursday, October 29, 2020 at 5:56:32 AM UTC+3 Kurtis Rader wrote: > I ran, in an interactive administrative

Re: [go-nuts] Trying to call powershell script from Go

2020-10-28 Thread Kurtis Rader
I ran, in an interactive administrative PowerShell session, this command: Set-ExecutionPolicy -Scope CurrentUser Unrestricted After doing that I was able to successfully run your program after changing "script.ps1" to ".\\script.ps1". That is, I saw "hello" and "err" was nil. On Wed, Oct 28,

Re: [go-nuts] Trying to call powershell script from Go

2020-10-28 Thread Kurtis Rader
Have you tried running the command directly from a Windows shell prompt? That is, opening a Windows cmd or powershell session and typing this: c:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe script.ps1 When I do that, after I create a file named "script.ps1" in my CWD that contains

Re: [go-nuts] Trying to call powershell script from Go

2020-10-28 Thread Uzair Ally
Hi Marvin, That was the issue. I removed the quotes from cmdName and the compiler identified it as a variable instead of a string. So I updated the code, removing the quotes from cmdName and it compiled, but I'm seeing the err output now and exit status 1 instead of actual output from the comm

Re: [go-nuts] Trying to call powershell script from Go

2020-10-28 Thread Uzair Ally
Hi Jake.. sorry for the confusion.. appreciate your input! On Wednesday, October 28, 2020 at 3:00:24 PM UTC+3 jake...@gmail.com wrote: > Technically your code is not runnable, since it does not compile. I > misunderstood, and thought you were having a problem with running a > powershell script

Re: [go-nuts] Trying to call powershell script from Go

2020-10-28 Thread jake...@gmail.com
Technically your code is not runnable, since it does not compile. I misunderstood, and thought you were having a problem with running a powershell script from Go, but actually you are having a problem compiling the code. Very different problems. So never-mind ;-) On Tuesday, October 27, 2020 at

Re: [go-nuts] Trying to call powershell script from Go

2020-10-27 Thread Marvin Renich
* Uzair Ally [201027 14:19]: > Hi Jake, > > The code I posted is the runnable go program just missing the powershell > script which is a separate file. Maybe I'm miss understanding? Is there > something else I can provide to help you understand further? Based on the your original message and t

Re: [go-nuts] Trying to call powershell script from Go

2020-10-27 Thread Uzair Ally
Hi Jake, The code I posted is the runnable go program just missing the powershell script which is a separate file. Maybe I'm miss understanding? Is there something else I can provide to help you understand further? On Tuesday, October 27, 2020 at 8:48:54 PM UTC+3 jake...@gmail.com wrote: > It

Re: [go-nuts] Trying to call powershell script from Go

2020-10-27 Thread Uzair Ally
Hi Ian, Thanks for your response! Yeah I'm only getting the error "cmdName declared but not used" when I add script.ps1 in double quotes. If I remove the double quotes from script.ps1 then the only error I see is undefined: script. The variable cmdName is set to call powershell.exe from it's p

Re: [go-nuts] Trying to call powershell script from Go

2020-10-27 Thread jake...@gmail.com
It might help if you posted an actual runnable program, that you have personally run, and the full output. On Tuesday, October 27, 2020 at 1:26:53 PM UTC-4 mua...@gmail.com wrote: > Hi Marvin, > > If I add script.ps1 in double quotes and try to run, it tells me cmdName > declared but no used.

Re: [go-nuts] Trying to call powershell script from Go

2020-10-27 Thread Ian Lance Taylor
On Tue, Oct 27, 2020 at 10:27 AM Uzair Ally wrote: > > > If I add script.ps1 in double quotes and try to run, it tells me cmdName > declared but no used. > Yes, the script is named script.ps1. The script is not a variable. Your program has basic issues with using the Go language. I recommend th

Re: [go-nuts] Trying to call powershell script from Go

2020-10-27 Thread Marvin Renich
* Uzair Ally [201027 13:27]: > Hi Marvin, > > If I add script.ps1 in double quotes and try to run, it tells me cmdName > declared but no used. > Yes, the script is named script.ps1. The script is not a variable. I should have recognized that "cmdName" should be cmdName without the quotes: ou

Re: [go-nuts] Trying to call powershell script from Go

2020-10-27 Thread Uzair Ally
Hi Marvin, If I add script.ps1 in double quotes and try to run, it tells me cmdName declared but no used. Yes, the script is named script.ps1. The script is not a variable. On Tuesday, October 27, 2020 at 8:22:14 PM UTC+3 Marvin Renich wrote: > * Uzair Ally [201027 12:25]: > > Hi, > > > > I a

Re: [go-nuts] Trying to call powershell script from Go

2020-10-27 Thread Marvin Renich
* Uzair Ally [201027 12:25]: > Hi, > > I am getting the following error when I try to call a powershell script > from go. > > undefined: script > > Here is the code: > > cmdName := "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" > out, err := exec.Command("cmdName", script.ps

Re: [go-nuts] Trying to call powershell script from Go

2020-10-27 Thread Uzair Ally
Hi Ian, Yes of course, here is the program. I am trying to use the os/exec package to call powershell then a script which is script.ps1. I have the script.ps1 in the same folder as main.go package main import ( "fmt" "os" "os/exec" ) func main() { cmdName := "C:\\Windows\\System32\\WindowsPow

Re: [go-nuts] Trying to call powershell script from Go

2020-10-27 Thread Ian Lance Taylor
On Tue, Oct 27, 2020 at 9:25 AM Uzair Ally wrote: > > I am getting the following error when I try to call a powershell script from > go. > > undefined: script > > Here is the code: > > cmdName := "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" > out, err := exec.Command("cmdName"

[go-nuts] Trying to call powershell script from Go

2020-10-27 Thread Uzair Ally
Hi, I am getting the following error when I try to call a powershell script from go. undefined: script Here is the code: cmdName := "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" out, err := exec.Command("cmdName", script.ps1).Output() if err != nil { fmt.Fprintln(os.Stderr,