Fred Stluka on 9 Apr 2012 06:42:18 -0700

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PLUG] Why does -t option of ssh cause mail to not be sent?...

Linux gurus,

Any idea why the -t option of ssh causes mail to not be sent when I
use the command:

    ssh -t ./junk

where ./junk contains:

    #!/bin/csh -f
    echo "hello" | mail -s "Test" fred

Works fine w/o the -t option.

The -t option causes ssh to allocate a "pseudo tty".  I don't know all
the ramifications of using a "pseudo tty", but -t is necessary when I
use ssh to execute a sudo command, so I tend to use it all the time.
For more info on that, see:

In this case, it seems that the script ends before the e-mail gets
fully handed off to sendmail or something, and so the ssh session
terminates and the mail never gets sent.

Works fine if I do any of the following:
- Not use -t
- Add a sleep command to the end of the script, to slow it down, like:
        sleep 1
- Use -v (verbose) option on mail to cause it to display details of
   delivery to the terminal.

I've been doing a tail-f of the mail log.  When the mail doesn't get send,
there are no log entries at all.

Any explanations?

Fred Stluka -- --
Bristle Software, Inc -- -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.
Philadelphia Linux Users Group         --
Announcements -
General Discussion  --