Running the workflows thru Ruby and Test gets passed but the workflows does not trigger

47 Views Asked by At

I am trying to run the informatica workflows thru ruby. Using the Net-ssh gem. When i run my test it gets passed but my jobs are not triggered when i check the logs they are not creating.

Below is my code.

Given(/^Run ESP jobs$/) do
  require 'net/ssh'
  Net::SSH.start('host', 'user', :password => "my_password" ) do
    # I am trying to connect to remote server.
    ssh.exec('cd /etl/dev/scripts/bin')
    puts ssh.exec('pwd')
    # After changing the directory i tried to see my path but my path still 
    # shows in the home 
    # below command is in this path "/etl/dev/scripts/bin"
    ssh.exec('startworkflow01.ksh folder_name workflow_name')
  end
end

I expect to run the job. Please provide me your suggestions in completing this task. Thanks for your valuable time.

1

There are 1 best solutions below

4
Casper On

Neither exec nor exec! will preserve state between calls, since those commands are not running on top of a shell like Bash or Zsh.

Therefore to run a script in a certain folder you either have to address the script with an absolute path:

ssh.exec!("/the/path/to/my_script")

Or string related commands together with ; in the same exec call, to preserve state:

ssh.exec!("cd /the/path/to; my_script; ...")

If you want to run everything on top of a real shell, then it gets more complicated. I recommend to look here for more details on that:

ruby net-ssh login shell