Conor Schaefer on 9 Apr 2012 06:48:37 -0700

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

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

In my experience, the -t option is useful when I want something to enjoy a screen of its own, i.e. to remain running. Case in point: from my laptop I can easily:


Then I'm right back at my local laptop prompt, which the output of "ls" from my server's home directory printed above. This command, however, would fail with "Error opening terminal: unknown.":


because htop requires a screen to display on.

Try specifying a full path when calling your "junk" script. In glancing over the manpage for SSH, I can't tell what environment those pseudo-ttys inherit; I'd imagine the normal user environment, but try anyway.

On Mon, Apr 9, 2012 at 9:42 AM, Fred Stluka <> wrote:
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 Â-- Â

Philadelphia Linux Users Group         --
Announcements -
General Discussion  --