【问题标题】:Running the workflows thru Ruby and Test gets passed but the workflows does not trigger通过 Ruby 和测试运行工作流通过,但工作流不会触发
【发布时间】:2019-07-30 05:18:44
【问题描述】:

我正在尝试通过 ruby​​ 运行 informatica 工作流程。使用 Net-ssh gem。当我运行我的测试时,它通过了,但是当我检查他们没有创建的日志时,我的工作没有被触发。

下面是我的代码。

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

我希望能胜任这份工作。请在完成此任务时向我提供您的建议。感谢您宝贵的时间。

【问题讨论】:

  • @engineersmnky 感谢您的回复,我确实尝试过使用 exec!。 Given(/^Run ESP jobs$/) 确实需要 'net/ssh' Net::SSH.start('host', 'user', :password => "my_password" ) do |ssh| ssh.exec!('cd /etl/dev/scripts/bin') puts ssh.exec!('pwd') ssh.exec!('startworkflow01.ksh folder_name workflow_name') end end 测试通过了,但是如果我检查他们没有生成任何日志的日志。当我通过 linux 手动运行时,它可以工作。

标签: ruby net-ssh


【解决方案1】:

execexec! 都不会在调用之间保留状态,因为这些命令不是在像 Bash 或 Zsh 这样的 shell 之上运行的。

因此,要在某个文件夹中运行脚本,您必须使用绝对路径来寻址脚本:

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

或在同一个exec 调用中将相关命令与; 一起字符串,以保留状态:

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

如果你想在一个真实的 shell 上运行所有东西,那么它会变得更加复杂。我建议在这里查看更多详细信息:

ruby net-ssh login shell

【讨论】:

  • 感谢您的回复。我尝试使用下面的代码 Given(/^Run informatica jobs$/) do require 'net/ssh' Net::SSH.start('host', 'user', :password => "password" ) do |ssh| ssh.exec!( '/etl/dev/scripts/bin/startworkflow01.ksh app_CCMLB_FPERX wf_4100_CCML_CAP_PKG_EXT') end end 我还是没有看到任何日志。
  • startworkflow01.ksh 是否需要一个特定的工作目录?它是否期望存在其他 shell 变量?请注意,它不是登录 shell,因此不会运行 .bashrc 文件来设置您的环境。
  • 我有点能够更改目录。当我运行测试时,我得到了这个 bash: startworkflow01.ksh: command not found。 startworkflow01.ksh 存在于上述路径中。我不确定这意味着什么。
  • 您应该使用./startworkflow01.ksh 运行它。注意点和斜线。就像我说的那样,您的环境将不会设置。如果它不起作用,你最好改用Net::SSH::Shell 之类的东西:github.com/mitchellh/net-ssh-shell
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-02-06
  • 1970-01-01
  • 2010-09-13
  • 1970-01-01
相关资源
最近更新 更多