Powershell

Hello
I am planning to execute a powershell and i want to execute it through knime. It is just a basic powershell, I am just checking how to use it with knime. It is saved as new.ps1

how can i execute the powershell new.ps1?
Thanks

Have you tried the External Tool or External Tool (Labs) nodes?

Yeah but it doesnt give me the output.
It would be great if you can provide a sample WF with .ps1 extension.
Thanks a lot.

Not even if you provide a location for the output file in the dialog below?

I will confess that I haven’t used this node much myself. Maybe I can generate an example, but I’ll also need to prepare a powershell file to play with too.

1 Like

Here’s something that seems to work - a workflow and associated “Hello World” PS script. You’ll need to change the configuration of the node to match your own directory structure of course. You’ll also need to change the extension of the txt file back to .ps1 (since the forum doesn’t allow upload of ps1 files).

2019-03-27%2013_22_32-KNIME%20Analytics%20Platform

ExternalToolPowershellExample.knwf (7.1 KB)
hw.txt (52 Bytes)

3 Likes

Thanks a lot :slight_smile:

1 Like

The power-shell creates a csv, the external node in knime is executing the script and showing the output in tool output but says the node created an empty table
It also does’nt show the output in the external output of the external tool node.
Can you help me with this?
Thanks

Can you post a screenshot of the External Tool configuration? Possibly you don’t have the directory paths set correctly. I’m not sure why the node would create an empty table for you - for me the results look like this:

ps1)

Attached the config and the snapshot of the data
Thanks :slight_smile:


image

It’s a little hard to tell from just screenshots, but I’m guessing there are a couple of things going on. (I could be wrong!)

  1. Your Powershell script is writing to stdout, and not to an output file. The node is looking for a file to send to its output port, as specified in the Output Data File section of the dialog.

  2. Your column separator looks like it’s an apostrophe - is this correct?

If you’re still having trouble, at this point it might be best to post your workflow and PS script as toy examples, without any confidential data.

Thanks for the help scott

@ScottF,
can we pass parameters to the command line in the external tool from a flow variable?
I want to dynamically pass the input constraints to the command line in the external tool via workflow credentials, is it possible?
please help me with that.
Thanks,
Pruthvi

Yes, this should be doable. Let’s say I create a workflow variable called MyParams that contains some command line functionality I want to use later.

2019-04-11%2016_16_19-Add_Edit%20Workflow%20Variable

Then, referring to this variable later in the External Tool node is straightforward.

Also, using global workflow variables isn’t strictly necessary here - I could also use a String Input quickform node to create the flow variable as well.

1 Like

Hello @ScottF,
The external tool has to execute a statement in cmd prompt which evoked OBIEE Client and does an operation.
There is not specific input and output file for the intended task but i passed dummies. The external tool shows that it is executed but the result of the intended task of creating a new file is not done. Please help me with this.Attaching the command.

I’m not sure offhand why you are not seeing the expected results. But there’s another node you can try that is a little less finicky than the External Tool node - you might try this and see if you have a different result.

Thanks for the reply @ScottF.

I have a csv read into my Knime local and executed.
I want to export my knime workflow now. I was wondering if i can also export the csv file ( in my local) along with the knime workflow as a package(without sending the actual csv separately)? so that the end user has the data .
Thanks in advance

You can! Here’s a blog article where a method for doing this is presented. Scroll down to Keeping Your Data with Your Workflow: https://www.knime.com/blog/tips-tricks-for-using-knime-analytics-platform-today-bunny-ears-metanodes-co

1 Like

@ScottF
I have few csv files as output for a workflow.
So instead of reading csv everytime from local I want to call the before workflow and csvs in it into the new workflow.
I’ve tried the call local workflow node but it didn’t work.
Can you please help me with a sample workflow where I can call the previous workflow and also mention which csv I need through an input to the call workflow node.
Thanks a lot in advance.

Sounds odd. You better keep you previous data on database like SQLite.

There may be easier ways to do this than using the call workflow nodes. If you’re concerned about reading in some static data, why not write out the results of your previous workflow to a database or KNIME table, as @izaychik63 suggests?

Alternately, you could take the previous workflow, wrap it in a metanode, and create a metanode template for re-use. See below for more on that: https://www.knime.com/blog/wrapped-metanodes-and-metanode-templates-in-knime-analytics-platform