I am trying to run a PHP script inside the ruby shell. While it is working perfectly if I am using the snippet directly in the ssh terminal, it is returning an error if executed with ruby:
zsh:1: command not found: php
Using this script below with commands like ls is working fine.
require 'rubygems'
require 'net/ssh'
host = "abc.de"
user = "user_xy"
pass = "user_pass"
begin
Net::SSH.start(host, user, :password => pass) do |ssh|
$a = ssh.exec! "cd xy_dir && php abc.phar do_this"
ssh.close
puts $a
end
rescue
puts "Unable to connect to #{host}."
end
How can I run PHP using Net::SSH?
Thanks for your help