Run ssh with Snaplogic script snap

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

Were you able to find a solution for this? I was hoping to call ssh from a pipeline, possibly using something like http://www.jcraft.com/jsch/ (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)

Thank you very much!

I will digest this, might follow up with you again.

Thanks,

Jibo

or unix execute snap can be used.

UNIX Execute Snap!? Is that something custom you have? I don’t see such a thing.

1 Like

it must me a custom snap, you can ask your account manager to get it