SSH hangs for a particular command in SSH.exec!(cmd)

Hi All,

   I am trying to connect the remote ssh server via ruby using
Net::SSH.It is working fine for me for all the commands provided via
script and i could able to read the output of the command successfully.
But when i use the below command it is getting stuck in SSH.exec!(cmd)
and control is not returned from the line. Only if i click Ctrl+c in
command line the script is getting ended.
The command is ./wcsadmin.sh start --> this is used to start the
processes of my application in remote server

Please find the below code snippet of my ruby script:

    Net::SSH.start(host, username, :password => password) do |ssh|
    puts 'before exit'
    output = ssh.exec!(/opt/wcsadmin.sh start)
    puts 'Executed command'

The output of the command when i do it manually is :

[root@test bin]# ./wcsadmin.sh start

Starting Network Control System...

This may take a few minutes...
stty: standard input: Invalid argument

Network Control System started successfully.

Starting SAM daemon...
Done.
Starting DA daemon...
Starting DA syslog daemon...
start

if i use ssh.exec('./wcsadmin.sh start') the only difference is the
above output is getting printed but still the program is never ended.I
need to manually end it by hitting ctrl+c.When i searched in google i
could find you can use nohup command('nohup /opt/wcsadmin.sh start

/tmp/teststartserver.log 2>&1') to skip the hangup signals and tried

the same.This also writes the output to teststartserver.log but getting
hanged.Can anyone please help me out on this issue?

Thanks in Advance!

Thanks,
Meena

···

--
Posted via http://www.ruby-forum.com/.

the command to be execed should be in string format, so you' ll have
to enclose it in quotes..

kind regards -botp

···

On Thu, Mar 22, 2012 at 3:12 PM, Meena Valliappan <lists@ruby-forum.com> wrote:

output = ssh.exec!(/opt/wcsadmin.sh start)

botp wrote in post #1052757:

output = ssh.exec!(/opt/wcsadmin.sh start)

the command to be execed should be in string format, so you' ll have
to enclose it in quotes..

kind regards -botp

Hi Botp,

  Thanks for your quick reply. I missed to add the same while posting
it(it is a Typo). i am using the command with quotes only as below:

    Net::SSH.start(host, username, :password => password) do |ssh|
    puts 'before exit'
    output = ssh.exec!('/opt/wcsadmin.sh start')
    puts 'Executed command'

But still facing the issue. Please help me.

Thanks,
Meena

···

On Thu, Mar 22, 2012 at 3:12 PM, Meena Valliappan <lists@ruby-forum.com> > wrote:

--
Posted via http://www.ruby-forum.com/.

1 check your logs
2 check your username, it might not be root
3 try using the block format of ssh exec

btw, pls show versions of ruby and net-ssh and actual screenshots

kind regards -botp

···

On Thu, Mar 22, 2012 at 3:36 PM, Meena Valliappan <lists@ruby-forum.com> wrote:

Net::SSH.start(host, username, :password => password) do |ssh|
puts 'before exit'
output = ssh.exec!('/opt/wcsadmin.sh start')
puts 'Executed command'