muizelaar has asked for the wisdom of the Perl Monks concerning the following question:

I’m not sure if this could be classed as a Perl problem or a Solaris 10 problem or a bit of both. I have setup ssh on two servers which allows me to run a perl script on the client side which makes a call to the remote server to run another Perl script which in turn starts an application. The application starts ok but the problem is the ssh connection does not disconnect and is waiting for some kill or escape sequence to close the connection and kill the process. Can anyone help me?
#!/usr/bin/perl -w system("ssh adm\@testsrvr /home/adm/teststart"); exit 0;

Replies are listed 'Best First'.
Re: ssh connection
by Bloodnok (Vicar) on May 21, 2009 at 15:06 UTC
    In addition to the AM suggestion, you might want to check that /home/adm/teststart returns to command prompt once the application has started - otherwise, your ssh session will wait until the script does return to command prompt.

    Typically, you might have the following in /home/adm/teststart to achieve the desired functionality (unless the application knows how to trun itself into a daemon):

    . . # Start the app and return nohup /usr/bin/some_app >/dev/null 2>&1 & . .
    nohup(1) allows the application to carry on running once the controlling, in this case the login, session has terminated.

    A user level that continues to overstate my experience :-))
Re: ssh connection
by Utilitarian (Vicar) on May 21, 2009 at 15:07 UTC
    From the ssh man page
    BatchMode: If set to “yes”, passphrase/password querying will be disab +led. This option is useful in scripts and other batch jobs where no +user is present to supply the password. The argument must be “yes” or + “no”. The default is “no”.
    So running
    ssh -o BathMode=yes user@host.with.key.exghange "command"
    Should do the business
      Thank you ;-)
Re: ssh connection
by Anonymous Monk on May 21, 2009 at 14:32 UTC
    You might need to redirect all I/O:
    #!/usr/bin/perl -w system("ssh adm\@testsrvr /home/adm/teststart </dev/null >/dev/null 2> +&1&"); exit 0;
      Hi Anonymous Monk That worked a treat thanks for all your help exactly what I wanted. :-)