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:

ssh SERVERALIAS ls

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.":

ssh SERVERALIAS htop

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 <fred@bristle.com> wrote:
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

___________________________________________________________________________
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