Operating System - HP-UX
1752777 Members
6065 Online
108789 Solutions
New Discussion юеВ

Re: Need help with SSH/Job Control

 
SOLVED
Go to solution
Mel Burslan
Honored Contributor

Re: Need help with SSH/Job Control

Matti,

All maybe/is well what you are saying in your answer about the non-interactive logins, but I have or had the same problem with my interactive ssh sessions. And for what I know, I need to give input to those screens and need to see something on the stdout, which was tty..

Do you have any idea why those sessions were hung and how to circumvent it ?
________________________________
UNIX because I majored in cryptology...
Matti_Kurkela
Honored Contributor

Re: Need help with SSH/Job Control

Mel,

do you use X11 forwarding or other TCP connection forwarding with your sessions? If there is a forwarded connection still active when you log out of the shell connection, the ssh will "hang" until the forwarded connection gets closed. To confirm this, enter "~#" to a "hung" SSH session. It should list the active connections. Entering "~." would force the session to disconnect.

It seems there has also been a bug in the OpenSSH code which might be related to your problem. Version 3.71 (and maybe before) had the problem, 3.81 had a tentative solution, and 3.9+ should have a final solution for this bug.
MK
Andrei Lica_1
Advisor

Re: Need help with SSH/Job Control

Matti Kurkela is right : the command that you run remotely is hanging on stdout or stderr or both.
It took 1 day for me to figure that out.
This is valid only for some commands/processes ( for me was java binary .. ) and you cannot hide those commands by using wrapper scripts.
Using explicit exit commands doesn't solve the problem either.
Instead redirect stdout and stderr to normal files or to /dev/null ( if you don't need the output ) :
$ ssh remhost "cmd 1>/tmp/cmd.out 2>/tmp/cmd.err"
It isn't an elegant solution but it works

andrei

Bob_Vance
Esteemed Contributor

Re: Need help with SSH/Job Control

FYI
The use of the tilde should be perfectly fine!

There is a misconception about the ~ -- it does *not* a generate relative pathname!
The shell will convert it to an absolute name prior to being passed to the program.

From 'man sh-posix' :

After alias substitution is performed, each word is checked to see if
it begins with an unquoted tilde (~). If it does, the word up to a /
is checked to see if it matches a user name in the /etc/passwd file.
If a match is found, the ~ and the matched login name are replaced by
the login directory of the matched user.


Also, using an arg dump program:

Pine3 ## args ~bobv |head
These are the execution-time arguments:
args
/home/.bobvance


hth
bv
"The lyf so short, the craft so long to lerne." - Chaucer
Jason Martens
Frequent Advisor

Re: Need help with SSH/Job Control

Thanks all for your help!

Matti Kurkela and Andrei Lica, redirecting the output and input to /dev/null did indeed solve my problem; mostly anyways. I used Matti's example, and it worked great. Only it would be nice to capture the output still, so if someone has a convenient way to do this, and include it in the e-mailed job that would be great.

Also, I tried the -n option to ssh, and that did not help for me.

I also upgraded to the most recent version of ssh (4.0.something) and that did not seem to make a difference.

And lastly, the explicit exit commands also did not help in this case.

Thanks again all.
Jason
Never swap out a tape drive at 3 AM!!!
Jason Martens
Frequent Advisor

Re: Need help with SSH/Job Control

Oh, and the sudo suggestion is a good one. However, I have run into this problem before with sshing between machines, so I figured this was a good time to debug it.
Never swap out a tape drive at 3 AM!!!
Andrei Lica_1
Advisor

Re: Need help with SSH/Job Control

To capture/process the output you could try :
1. Redirect stdout/err to files then scp the files to local files, process the files.
2. Try to use perl ssh module[s] : http://search.cpan.org/~dbrobins/Net-SSH-Perl-1.28/lib/Net/SSH/Perl.pm