Issue while ruby script execution

Hi,
I have an issue with executing ruby script from my dial plan.
While my dial plan executing I want to call ruby script where I doing ssh connection to remote.
My ruby script executes SSH connection to remote server and executing other script on it.
This script is working fine when I run it manually from terminal:
[root@asterisk scripts]# ruby test.rb
it works fine when I executing it from asterisk console:
asterisk*CLI> !/srv/nfs/scripts/test.rb

But my trubles starting when want do to the sane in dail plan.
This is try it
same => n,AGI(/srv/nfs/scripts/test.rb)
and
same => n,System(/srv/nfs/scripts/test.rb)

Please help me to understand what I am doing wrong or this is some asterisk bug issue.

[script]

#!/usr/bin/env ruby
require ‘net/ssh’

HOST = ‘192.168.56.102’ #Remote server
USER = 'root’
PASS = 'xxxxxxx’
command="ruby /home/ubuntu/Documents/prototype/public/nfs-share/scripts/update_db.rb"
puts command
Net::SSH.start( HOST, USER, :password => PASS ) do|ssh|
result = ssh.exec!(command)
puts result
end
puts “ssh_update_END”

When you do it from the console, you are really doing it from the shell, in the context of the client process. When you run it from the dialplan, you are doing it in the context of the main Asterisk process. That means it can be affected by differences in the setting of the PATH environment variable and by differences in permissions.

Hi David,
Thanks for a help, my problem solved when I change env for asterisk user: fot this PATH=/usr/local/rvm/gems/ruby-1.9.2-p320/bin:/usr/local/rvm/gems/ruby-1.9.2-p320@global/bin:/usr/local/rvm/rubies/ruby-1.9.2-p320/bin:/usr/local/rvm/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin