"The term '-Command' is not recognized as the name of a cmdlet" when trying to execute an inline command in PowerShell Core on Ubuntu - .net-core

I'm trying to execute an inline command in PowerShell Core (6.2.3) on Ubuntu.
This throws an error:
pwsh -Command "Write-Host 'Hello, world'"
-Command : The term '-Command' is not recognized as the name of a cmdlet, function, script file, or operable program.
I installed PowerShell as a dotnet core global tool if that makes a difference.

Pass the command without a parameter name:
pwsh "Write-Host 'Hello, world'"
Microsoft's documentation shows that the parameter name is required, so maybe this is a quirk of installing pwsh as a dotnet core tool.

Related

Karate Runner -> karate jar : Command line args settings issue

I am using Visual Studio code and Karate Runner plugin is installed. Using karate-config.js with standalone jar (karate.jar). I have tried to configure in karate runner settings in VS code for Karate Runner -> karate jar : Command line args as "java -Dkarate.config.dir=test/resources/ -cp karate.jar com.intuit.karate.Main" but it throws an exception like
Executing task: java -Dkarate.config.dir=test/resources/ -cp karate.jar com.intuit.karate.Main "d:\GitHub\KarateTestFramework\test\features\script\all_users.feature:9" <
Error: Could not find or load main class .config.dir=test.resources.
The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command java -Dkarate.config.dir=test/resources/ -cp karate.jar com.intuit.karate.Main "d:\GitHub\KarateTestFramework\test\features\script\all_users.feature:9"" terminated with exit code: 1.
Terminal will be reused by tasks, press any key to close it.
Also, I have tried full path for -Dkarate.config.dir=D:/GitHub/KarateTestFramework/test/resources but didn't work either.
Please guide me to resolve this issue.
#ChandramohanRamabadran, I tried to replicate the issue on my system. I believe it's not a bug!
It's happening because your VisualStudio is using PowerShell instead of CMD. I believe you might have missed the step to change the default shell of VisualStudio after installing Karate. Try updating the default shell from PowerShell to CMD; then you should be good.
However, if you still want to use PowerShell, then update the command
java -Dkarate.config.dir=test/resources/ -cp karate.jar com.intuit.karate.Main
to
java `-Dkarate.config.dir`=test/resources/ -cp karate.jar com.intuit.karate.Main
More context over the issue:
PowerShell has a more standard rule to parse system-properties parameters which are different from CMD. In a PowerShell command, the parameter names always begin with a hyphen. The hyphen tells PowerShell that the item in the command is a parameter name.
Here, we are passing the parameter as -Dkarate.config.dir, PowerShell sights the parameter name-tag as -Dkarate and not -Dkarate.config.dir; hence the error.
This is a bug. Thanks for reporting it: https://github.com/intuit/karate/issues/1330
For now please find a workaround. Karate will look for karate-config.js in the current directory or the classpath. So if you change the command to something like this (please try variations) it should work
-cp 'karate.jar;test/resources/'
I have changed preferred terminal shell from Powershell to command as default for VS code and followed the below listed steps
Press Ctrl + Shift + P to show all commands.
Type shell in the displayed text box to filter the list.
Select Terminal: Select Default Shell .
You will be prompted to Select your preferred terminal shell, you can change this later in your settings or follow the same process as we do now.
I have changed the karate runner->karate jar:Command Line Args settings as java -Dkarate.config.dir=resources/ -cp karate.jar com.intuit.karate.Main
Now its working fine.

how can i use "|find" in robot frame work

I want to know the status of the virtual machine
In Command Prompt by executing the below command
C:\Program Files\Oracle\VirtualBox>vboxmanage showvminfo Linux |find "State:"
I got output as
=>State: running (since 2020-09-30T06:00:01.824000000)
the same thing when I tried in robot framework(RIDE)
#${result}= Run process C:\\Program Files\\Oracle\\VirtualBox\\VBoxManage showvminfo Linux |find "State:"
I am getting error as -
Syntax error: Invalid parameter '|find'
Can someone help how to use |find in robot framework.
Piping eg, using | character is shell feature. If you want to run shell commands or using features from it, you need to tell Run Process to run it inside a shell by adding shell=yes to your Run Process keyword.
This is documented in https://robotframework.org/robotframework/latest/libraries/Process.html#Process%20configuration and a section below it called Running processes in shell

Why my codelite execute 'make -j 0'

I'm using cmake-GUI on windows, generating for codelite, to build a simple "hello world" project (https://github.com/jameskbride/cmake-hello-world). I'm trying to use cygwin compilers but when I run the build command, I got the following error:
C:\WINDOWS\system32\cmd.exe /C C:/cygwin64/bin/make.exe -j 0
----------Building project:[ Debugging - Debug ]----------
make: the '-j' option requires a positive integer argument
Usage: make [options] [target] ...
Why it is happening?!?
My cygwin folder is in PATH. In cygwin terminal the project works.
Your project was generated by CMake - this means that the project is set to custom project so the command to execute (in your case make -j0) is set in the Project Settings->Customize->Custom build page.
On that page you have several entries with different titles (Build, Clean etc)
Double click each entry so it will open in Edit mode and remove the -j0 option
This looks like a bug in CodeLite - CMake generator

In which folder to run this PowerShell script?

I am following the example. It is publishing an ASP.NET application to a docker container on a remote Linux sever.
There is a small piece of work to run script.
Let's quote it.
Also be sure to explore the PublishProfiles folder that gets created
in your Visual Studio project under "Properties." A PowerShell script
and a Shell script get created in that folder that you can use to
publish your app from the command line. For example:
.\hanseldocker-Docker-publish.ps1 -packOutput $env:USERPROFILE\AppData\Local\Temp\PublishTemp -pubxmlFile .\hanseldocker-Docker.pubxml
I am not sure the location of .\. Actually I am using Bamboo to build it, I have to place the script into the body.
.
I don't know whether I should modify the script because of .\?
Get a solution at here.
To launch it using the regular old, command line and pass any powershell script as a parameters.
C:\Windows\System32\cmd.exe /c "echo Hesus | C:\WINDOWS\SysWOW64\WindowsPowerShell\v1.0\powershell.exe %*"
Put this in the Argument:
scripts\RemoteWSPDeployment.ps1 –parameter1 value1 –parameter2 value2

Brackets shell not running node commands

I have just installed the Brackets Shell extension (Mac OSX 10.9) and can run normal shell commands (ls, pwd), but not node commands (bower install, npm install). I get 'command not found'. Any suggestions?
Currently the brackets shell extension has a bug in that it is not reading your profile path environment. This is why you are receiving "command not found" in the console.
I'll be releasing an update to the shell extension this coming weekend (10/4/2014) which should resolve your issues.

Resources