Support Questions

Find answers, ask questions, and share your expertise

How to execute the .sh script on a remote server using NIFI

avatar
Contributor

I am working on a POC and I have installed the NIFI at my laptop, now i am trying to execute the SH script which hosted on Linux machine, could you guide me on step by steps.

6 REPLIES 6

avatar
Expert Contributor

You can use this processor to run the command through `ssh` command to that linux machine, like explained here.

avatar
Master Guru

I have a blog post that describes how to use ExecuteScript with Groovy and Sshoogr to execute remote commands via SSH. Not sure if this is what you're looking for but I thought I'd share in case it was useful.

avatar
Contributor

@Matt Thanks for the response. I saw your post and its good. My Requirement is, I have some .SH script which hosted on a Linux machine and i wanted to execute those script using the NIFI.

Issues:NIFI ruining at my laptop and I am trying to get the files from Linux machine how i can achive this ?

avatar
Contributor

Hi Matt, Do you have any template for that ?

avatar
Contributor

Hi Shakeel,

There is a python package called 'paramiko' that can ssh to a remote linux machine. All you need to do is to write the python script on your local windows machine. Give the hostname and other details to the paramiko object. Then you can use Nifi to run the paramiko.py script on local. This in turn will execute your remote .sh script.

Refer this post for reference: https://stackoverflow.com/questions/3635131/paramikos-sshclient-with-sftp''

Approach 2:

Use the ExecuteStream processor. The inputs are as below:

Command Arguments: user@servername;"bash <yourscript.sh> 2>&1"

Command Path: /usr/bin/ssh

This can execute a remote script if the server/computer is reachable from Nifi cluster. That means that your computer should be ping (able) from the Nifi machines.

If there are better solutions, please share.

avatar
Contributor

Thanks for the response, do you have template for that ?