cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Run ssh with Snaplogic script snap

walkerline117
Contributor

if our Snaplogic groudplex is running on a unix machine, can i write a script with script snap to run a ssh command in my pipeline?

Thanks

8 REPLIES 8

johnhwhite
New Contributor

Were you able to find a solution for this? I was hoping to call ssh from a pipeline, possibly using something like JSch - Java Secure Channel (which Snap Logic seems to use for SFTP) or similar package.

yes, we figured it out.

We used script snap with Python. Just few line of code. Simple enough

can you share your code ? thank you a lot

from com.snaplogic.scripting.language import ScriptHook
from com.snaplogic.scripting.language.ScriptHook import *
from subprocess import Popen, PIPE
import subprocess as subprocess

class TransformScript(ScriptHook):
def init(self, input, output, error, log):
self.input = input
self.output = output
self.error = error
self.log = log

def execute(self):
    self.log.info("Executing Transform script")
    proc = Popen(["ssh", "orsubdev@dev-server.com", " pwd "], shell=False, stdout=PIPE, stderr=PIPE)
    proc1 = Popen(["ssh", "orsubdev@dev-server.com", " 7za  x /dsdata/application/ORSUBDEV/CornerstoneLms/SourceFiles/testCasesSql.zip "], shell=False, stdout=PIPE, stderr=PIPE)
    out, err = proc.communicate()
    exitcode = proc.returncode
    proc.kill()
    self.output.write(out)
    self.log.info("Finished executing the Transform script")

hook = TransformScript(input, output, error, log)