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 mydomain.com ./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:
    http://bristle.com/Tips/Unix.htm#sudo_via_ssh
http://bristle.com/Tips/Unix.htm#use_scripts_for_frequent_ssh_access_to_bash

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
------------------------------------------------------------------------
Fred Stluka -- mailto:fred@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.
------------------------------------------------------------------------
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug