Cannot execute this command “rasa run actions & rasa shell” - rasa-nlu

Using Rasa open source I tried to execute (Windows Powershell) this command rasa run action & rasa shell it generate some error like this:
At line:1 char:17
+ rasa run action & rasa shell
+ ~
The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to
pass it as part of a string.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : AmpersandNotAllowed

In PowerShell you can use a semicolon to run 2 commands (note it should be rasa run actions):
rasa shell; rasa run actions
In cmd you can still use ampersand.
However this won't work on Windows where commands are run sequentially. One solution is to have a terminal session for each command (you also don't mix up logs and can restart only one if you need to)

You are trying to run 2 different commands on the shell. shell does not know "&".
Rasa run command is used to run the rasa framework as a server on localhost:5005
whereas
rasa shell is used to run on the chatbot on the terminal, the server will be started automatically.
I would prefer to run the command in 2 different shell to reduce the debug confusion

Related

How to run a CMD task inside of PowerShell?

I am trying to run a CMD task inside of a PowerShell script that will open up a new tab in Google Chrome. I am running this command inside an Azure DevOps pipeline.
The task I am attempting to run is:
start chrome --user-data-dir="ChromeProfiles\Profile$profile" --disable-default-apps --new-window "$($reportHtmlFile)"
When I run this command from my local command prompt, a new tab opens and works as expected. To run it from my PowerShell window I run:
cmd /c echo start chrome --user-data-dir="ChromeProfiles\Profile$profile" --disable-default-apps --new-window "$($reportHtmlFile)" | cmd.exe
Both the above commands work as expected however, trying to run them from Azure DevOps I am getting an error saying:
+ ... " --disable-default-apps --new-window "$($reportHtmlFile)"" | cmd.exe
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The string is missing the terminator: ".
At D:\Agent\instance01\Workspace\20\s\pbi-load-test-tool\Run_Load_Test_Only.ps1:59 char:1
+
Missing closing ')' in expression.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
I have tried the following:
"start chrome --user-data-dir="ChromeProfiles\Profile$profile" --disable-default-apps --new-window "$($reportHtmlFile)"" | cmd.exe
& "start chrome --user-data-dir="ChromeProfiles\Profile$profile" --disable-default-apps --new-window "$($reportHtmlFile)" | cmd.exe"
Is there a syntactical error or is this a shortcoming with Azure DevOps?
What's Going on:
Your arguments are getting mangled because they contain quotes.
When you run this the way you're running it now, PowerShell will try to handle the quotes in the arguments before passing it to the exe.
The solution: Use Splatting
Splatting is a part of the PowerShell language that lets you pass structured arguments to a command. You can Splat a [Hashtable] to provide named arguments (if you're calling a function or cmdlet). You can also Splat an [Object[]] to provide arguments positionally.
Create an array out of all of your arguments:
In your case, that would be:
$startArgs = #(
# The user-data-dir probably wants double quotes
# so we use backticks to embed them.
"--user-data-dir=`"ChromeProfiles\Profile$profile`""
'--disable-default-apps'
'--new-window'
"$($reportHtmlFile)"
)
Call with splatting:
start #startArgs
Doing things this way will ensure that each argument is sent exactly the way you want it, with complete control over how arguments will be quoted.
Also: avoid $profile
$profile is the name of an automatic variable in PowerShell pointing to the PowerShell profile. I suspect you're interested in a chrome profile, not a PowerShell profile, so I would pick a different variable name that would better describe your purpose, rather than risk having an automatic variable provide a bad result.

Alternative to base64 decode in powershell

I was following a guide to connect a database to kubernetes:
https://itnext.io/basic-postgres-database-in-kubernetes-23c7834d91ef
after installing Kubernetes (minikube) on Windows 10 64 bit:
https://minikube.sigs.k8s.io/docs/start/
I am encountering an issue with 'base64' where the DB is trying to connect and store the password. As PowerShell doesn't recognise it. I was wondering if anyone has any ideas how I could either fix this and still use windows or an alternative means that would enable me to continue with the rest of the guide?
Error Code:
base64 : The term 'base64' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:131
+ ... postgresql -o jsonpath="{.data.postgresql-password}" | base64 --decod ...
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (base64:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
export : The term 'export' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ export POSTGRES_PASSWORD=$(kubectl get secret --namespace default pos ...
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (export:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Windows Powershell Error message
The base64 cli found in Mac OS and some *nix distros is not available on Windows.
You could write a small function named base64 that mimics the behavior of the base64 unix tool though:
function base64 {
# enumerate all pipeline input
$input |ForEach-Object {
if($MyInvocation.UnboundArguments -contains '--decode'){
# caller supplied `--decode`, so decode
$bytes = [convert]::FromBase64String($_)
[System.Text.Encoding]::ASCII.GetString($bytes)
} else {
# default mode, encode ascii text as base64
$bytes = [System.Text.Encoding]::ASCII.GetBytes($_)
[convert]::ToBase64String($bytes)
}
}
}
This should work as a drop-in replacement for conversion between ASCII/UTF7 text and base64:
PS ~> 'Hello, World!' |base64 --encode
SGVsbG8sIFdvcmxkIQ==
PS ~> 'Hello, World!' |base64 --encode |base64 --decode
Hello, World!
To use with your existing scripts, simple dot-source a script with the function definition in your shell before executing the others:
PS ~> . .\path\to\base64.ps1
The above will work from a script as well. If you have a multi-line paste-aware shell (Windows' default Console Host with PSReadLine should be okay), you can also just paste the function definition directly into the prompt :)
You're trying to execute command lines on Windows that were written for Unix-like platforms, both in terms of:
the external utilities they expect (base64)
the shell syntax they use (export POSTGRES_PASSWORD=$(...); written for POSIX-compatible shells such as bash).
Mathias' helpful answer shows you how to emulate a base64 utility in PowerShell, and you may even be able to emulate the export shell command with additional, nontrivial effort, but not all cases can be handled that way, such as a command line that uses \" to escape " characters (this will break PowerShell's syntax, try echo "3\" of snow.").
Therefore, I suggest either running your commands as-is via WSL, if feasible, or taking the time to translate the command lines into PowerShell-native equivalents.

execute powershell commands with Lua

I have a program that I work with, that has an onboard lua compiler to allow for custom written actions.
Since the tool itself is very limited, especially if it goes for complex reactions over networks, I want to use Powershell over lua.
Methods like os.execute() or io.popen() use the standard command line from windows and not Powershell.
Is there a way to use Powershell with lua?
I tried to write a command line script with the Powershell editor and run this script with os.execute, but it opens it as a textfile, it would be better to write the commands directly in lua but if there is no other way, executing a Powershell script directly would also be fine. (In Windows itself you can execute the script with right mouse "click/Execute with Powershell")
-- You can generate PowerShell script at run-time
local script = [[
Write-Host "Hello, World!"
]]
-- Now create powershell process and feed your script to its stdin
local pipe = io.popen("powershell -command -", "w")
pipe:write(script)
pipe:close()
Your description of the problem makes it sound like you're using a command such as os.execute("powershellscript.ps1"), and that call invokes cmd.exe with your string as the proposed command line. Normally, Windows will open a .PS1 file for editing; this was a deliberate decision for safety. Instead, try altering the os.execute() command to explicitly call PS: os.execute("powershell.exe -file powershellscript.ps1"). If you need to pass parameters to your script, enclose them in {}. See https://msdn.microsoft.com/en-us/powershell/scripting/core-powershell/console/powershell.exe-command-line-help for more info on invoking PowerShell from the command line.

How do I run a non system command in ruby?

We have an automation script which we run in Windows command prompt.
We use it like 'Automate task 1'
Now I am trying to run it using ruby. I followed this SO post.
But since this is not a system command it doesn't get executed.
system('Automate task 1')
How do I excute such commands?
Note: We don't have access to type or source of that command nor knows where is the command stored. We just execute it in cmd.

How Secure is using execFile for Bash Scripts?

I have a node.js app which is using the child_process.execFile command to run a command-line utility.
I'm worried that it would be possible for a user to run commands locally (a rm / -rf horror scenario comes to mind).
How secure is using execFile for Bash scripts? Any tips to ensure that flags I pass to execFile are escaped by the unix box hosting the server?
Edit
To be more precise, I'm more wondering if the arguments being sent to the file could be interpreted as a command and executed.
The other concern is inside the bash script itself, which is technically outside the scope of this question.
Using child_process.execFile by itself is perfectly safe as long as the user doesn't get to specify the command name.
It does not run the command in a shell (like child_process.exec does), so there is no need to escape anything.
child_process.execFile will execute commands with the user id of the node process, so it can do anything that user could do, which includes removing all the server files.
Not a good idea to let user pass in command as you seem to be implying by your question.
You could consider running the script in a sandbox by using chroot, and limiting the commands and what resides on the available file system, but this could get complet in a hurry.
The command you pass will get executed directly via some flavor of exec, so unless what you trying to execute is a script, it does not need to be escaped in any way.

Resources