Fred Stluka on 9 Apr 2012 10:54:14 -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?...


Conor,

This command, however, would fail with "Error opening terminal: unknown.":
Right.  Similar to the reason I use ssh -t to run sudo commands.
It wants a terminal to prompt for password, if necessary.

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.
I'm not having any trouble finding the junk script.  It runs just fine.
The only problem is that the mail doesn't get sent unless there is
enough stuff after it in the script to give the mail time to be sent
before the script ends.  So, specifying the full path to the junk script
should not matter, right?


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

On 4/9/12 9:48 AM, Conor Schaefer wrote:
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 <mailto: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 <http://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 <mailto:fred@bristle.com>
    -- http://bristle.com/~fred/ <http://bristle.com/%7Efred/>
    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
___________________________________________________________________________
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