Hi,
i need to run multiple commands in a remote machine through ssh,but when i use change directory it doesnot works and defaultly save in a root and also copy command is not working:
here is my code:
#!/usr/bin/ruby
require ‘net/ssh’
#require 'mysql’
require ‘rubygems’
ruby_block “Transfer bits” do
block do
HOST = node[‘trans’][‘host’]
USER = node[‘trans’][‘username’]
PASSWORD = "#{node[‘trans’][‘password’]}"
Net::SSH.start( HOST, USER, :password => PASSWORD )do |ssh|
ssh.exec(“mysqldump -u#{node[‘trans’][‘login_user’]} -p#{node[‘trans’][‘login_password’]} magento > magentodb.sql; mysql -u#{node[‘trans’][‘login_user’]} -p#{node[‘trans’][‘login_password’]}bitnami_wordpress > wordpressdb.sql; mkdir Magentobits_V2; mv magentodb.sql Magentobits_V2; mv wordpressdb.sql Magentobits_V2; cp wordpress Magentobits_V2; tar cvzf Magentobits_V2.tar.gz /var/www/”)
end
end
end
Anybody ve idea in this or open3 connection in ssh ?
Thanks,
Indra
Hi,
I don't see where you are trying to change directories in that script.
Also, what is the home directory of the user specified by
node['trans']['username']. I would expect any files you create with
relative paths to be relative to that users home directory, given what
you have there. If the home directory is / that would explain why
your files are created in your root directory.
Can you expand on what you mean when you say that the copy isn't
working? Do you receive an error? If not, what behavior are you
seeing and what do you expect to see?
Cheers,
Steven
On Thu, Jul 31, 2014 at 7:39 AM, Indra k indra.k@cloudenablers.com wrote:
Hi,
i need to run multiple commands in a remote machine through ssh,but when
i use change directory it doesnot works and defaultly save in a root and
also copy command is not working:
here is my code:
#!/usr/bin/ruby
require 'net/ssh'
#require 'mysql'
require 'rubygems'
ruby_block "Transfer bits" do
block do
HOST = node['trans']['host']
USER = node['trans']['username']
PASSWORD = "#{node['trans']['password']}"
Net::SSH.start( HOST, USER, :password => PASSWORD )do |ssh|
ssh.exec("mysqldump -u#{node['trans']['login_user']}
-p#{node['trans']['login_password']} magento > magentodb.sql; mysql
-u#{node['trans']['login_user']}
-p#{node['trans']['login_password']}bitnami_wordpress > wordpressdb.sql;
mkdir Magentobits_V2; mv magentodb.sql Magentobits_V2; mv wordpressdb.sql
Magentobits_V2; cp wordpress Magentobits_V2; tar cvzf Magentobits_V2.tar.gz
/var/www/")
end
end
end
Anybody ve idea in this or open3 connection in ssh ?
Thanks,
Indra