backgrounded ssh tunnel waits for tunnel to close before exiting when

backgrounded ssh tunnel waits for tunnel to close before exiting when

am 07.04.2008 21:52:44 von inetquestion

For the script below can anyone tell me why the first call to this
function waits for 5 seconds before returning and the second call does
not? The only difference is piping the output through tee that I can
tell (aside from the port number). I've tried nohup'ing the ssh
call, but that didn't make any difference.




#!/usr/bin/
ksh

DoStuff()
{
echo "using port: $1"
ssh pdspsapp01 -L$1:hostname.company.com:$1 -f sleep 5
echo "Debug: A, `date +%M:%S"
}

DoStuff 5000 | tee -i test.log
echo "Debug: B, `date +%M:%S"

DoStuff 5001
echo "Debug: B, `date +%M:%S"

Re: backgrounded ssh tunnel waits for tunnel to close beforeexiting when

am 08.04.2008 20:53:43 von Dan Stromberg

On Mon, 07 Apr 2008 12:52:44 -0700, inetquestion wrote:

> For the script below can anyone tell me why the first call to this
> function waits for 5 seconds before returning and the second call does
> not? The only difference is piping the output through tee that I can
> tell (aside from the port number). I've tried nohup'ing the ssh call,
> but that didn't make any difference.
>
>
>
>
> #!/usr/bin/
> ksh
>
> DoStuff()
> {
> echo "using port: $1"
> ssh pdspsapp01 -L$1:hostname.company.com:$1 -f sleep 5 echo "Debug:
> A, `date +%M:%S"
> }
>
> DoStuff 5000 | tee -i test.log
> echo "Debug: B, `date +%M:%S"
>
> DoStuff 5001
> echo "Debug: B, `date +%M:%S"

You might try:

ssh pdspsapp01 -L$1:hostname.company.com:$1 -f sleep 5 > /dev/null 2>&1
< /dev/null

I believe tee is probably waiting until all producer processes exit.

Re: backgrounded ssh tunnel waits for tunnel to close before exiting

am 09.04.2008 03:45:50 von inetquestion

On Apr 8, 2:53 pm, Dan Stromberg wrote:
> On Mon, 07 Apr 2008 12:52:44 -0700,inetquestionwrote:
> > For the script below can anyone tell me why the first call to this
> > function waits for 5 seconds before returning and the second call does
> > not? The only difference is piping the output through tee that I can
> > tell (aside from the port number). I've tried nohup'ing the ssh call,
> > but that didn't make any difference.
>
> > #!/usr/bin/
> > ksh
>
> > DoStuff()
> > {
> > echo "using port: $1"
> > ssh pdspsapp01 -L$1:hostname.company.com:$1 -f sleep 5 echo "Debug:
> > A, `date +%M:%S"
> > }
>
> > DoStuff 5000 | tee -i test.log
> > echo "Debug: B, `date +%M:%S"
>
> > DoStuff 5001
> > echo "Debug: B, `date +%M:%S"
>
> You might try:
>
> ssh pdspsapp01 -L$1:hostname.company.com:$1 -f sleep 5 > /dev/null 2>&1
> < /dev/null
>
> I believe tee is probably waiting until all producer processes exit.

I tried this and it works, but I don't understand why. I had tried ">/
dev/null 2>&1" before, just not the last part you added. Can you
explain the significance of redirecting stdin to /dev/null?

just want to make sure I understand what is going on for future
reference.

Thanks again!