ssh redirection - SSH

This is a discussion on ssh redirection - SSH ; Info: OpenSSH_3.0.2p1, SSH protocols 1.5/2.0, OpenSSL 0x0090603f Running on AIX 4.3 A script that we've converted to run a ssh command instead of rsh (due to requirements of a client) is behaving strangely with regards to the redirection. When the ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: ssh redirection

  1. ssh redirection

    Info:
    OpenSSH_3.0.2p1, SSH protocols 1.5/2.0, OpenSSL 0x0090603f
    Running on AIX 4.3

    A script that we've converted to run a ssh command instead of rsh (due
    to requirements of a client) is behaving strangely with regards to the
    redirection. When the script is run from the command line (and say the
    ssh command is ssh -l remotelogin remoteserver command > ssh.log 2>1&)
    then this works fine. The results of the command are piped to the log
    file fine.

    However, the script is actually called from program running on the
    server and for some reason, the log file changes to zero bytes (so the
    script is trying to do something) but there is nothing else in the
    file. When we were using rsh, it worked perfectly and we got results in
    the log file.

    Is there a specific reason why this would not work? Oy sysadmin thinks
    it could be to not having a tty for when the script is called.

    TIA,
    Martin


  2. Re: ssh redirection

    martinhanna@gmail.com wrote:
    > Info:
    > OpenSSH_3.0.2p1, SSH protocols 1.5/2.0, OpenSSL 0x0090603f
    > Running on AIX 4.3
    >
    > A script that we've converted to run a ssh command instead of rsh (due
    > to requirements of a client) is behaving strangely with regards to the
    > redirection. When the script is run from the command line (and say the
    > ssh command is ssh -l remotelogin remoteserver command > ssh.log 2>1&)
    > then this works fine. The results of the command are piped to the log
    > file fine.
    >
    > However, the script is actually called from program running on the
    > server and for some reason, the log file changes to zero bytes (so the
    > script is trying to do something) but there is nothing else in the
    > file. When we were using rsh, it worked perfectly and we got results
    > in the log file.
    >
    > Is there a specific reason why this would not work? Oy sysadmin thinks
    > it could be to not having a tty for when the script is called.


    It sounds like the presence of a pty makes a difference. Take a look at the
    "-T" and "-t" options.



  3. Re: ssh redirection

    No luck with that.

    -t gives the error : "Pseudo-terminal will not be allocated because
    stdin is not a terminal."
    -T sporadically gave some output sometimes, nothing other times.

    Weird.


  4. Re: ssh redirection


    > Info:
    > OpenSSH_3.0.2p1, SSH protocols 1.5/2.0, OpenSSL 0x0090603f
    > Running on AIX 4.3
    >
    > A script that we've converted to run a ssh command instead of rsh (due
    > to requirements of a client) is behaving strangely with regards to the
    > redirection. When the script is run from the command line (and say the
    > ssh command is ssh -l remotelogin remoteserver command > ssh.log 2>1&)
    > then this works fine. The results of the command are piped to the log
    > file fine.
    >
    > However, the script is actually called from program running on the
    > server and for some reason, the log file changes to zero bytes (so the
    > script is trying to do something) but there is nothing else in the
    > file. When we were using rsh, it worked perfectly and we got results in
    > the log file.


    Please be more specific -- i.e., include the script you're talking about
    (or the salient parts of it if it's large), and the exactly ssh command
    used.

    --
    Richard Silverman
    res@qoxp.net


  5. Re: ssh redirection

    The script is being called by a running program. Basically the script
    has the ssh command:

    ssh -l remotelogin remoteserver "command" > result.log 2>&1

    The results of the command should pipe to the result.log file but when
    called from the program the log file only gets created with zero bytes.
    Note that the command is actually running ok. It's the output in the
    log file that we're interested in since it verifies the command ran ok.

    To duplicate the problem the sysadmin has the same command in a cron
    job

    08 21 * * 1,2,3,4,5 . /etc/company_profile; /user/bin/sshtest.ksh

    with sshtest.ksh holding:

    ssh -l remotelogin remoteserver "command" > result.log 2>&1

    Again, the resulting file was 0 bytes.

    Our sysadmin reckons the issue is to do with the script being called
    not having a tty assigned to it.


  6. Re: ssh redirection


    On 8 Feb 2006 13:19:01 -0800, martinhanna@gmail.com wrote:

    >The script is being called by a running program. Basically the script
    >has the ssh command:
    >ssh -l remotelogin remoteserver "command" > result.log 2>&1
    >The results of the command should pipe to the result.log file but when
    >called from the program the log file only gets created with zero bytes.
    >Note that the command is actually running ok. It's the output in the
    >log file that we're interested in since it verifies the command ran ok.
    >To duplicate the problem the sysadmin has the same command in a cron
    >job
    >08 21 * * 1,2,3,4,5 . /etc/company_profile; /user/bin/sshtest.ksh
    >with sshtest.ksh holding:
    >ssh -l remotelogin remoteserver "command" > result.log 2>&1
    >Again, the resulting file was 0 bytes.
    >Our sysadmin reckons the issue is to do with the script being called
    >not having a tty assigned to it.



    Try this:

    ssh -n -l remotelogin remoteserver "command" > result.log 2>&1








  7. Re: ssh redirection

    Nomen Nescio wrote:
    > On 8 Feb 2006 13:19:01 -0800, martinhanna@gmail.com wrote:
    >
    >> The script is being called by a running program. Basically the script
    >> has the ssh command:
    >> ssh -l remotelogin remoteserver "command" > result.log 2>&1
    >> The results of the command should pipe to the result.log file but when
    >> called from the program the log file only gets created with zero bytes.
    >> Note that the command is actually running ok. It's the output in the
    >> log file that we're interested in since it verifies the command ran ok.
    >> To duplicate the problem the sysadmin has the same command in a cron
    >> job
    >> 08 21 * * 1,2,3,4,5 . /etc/company_profile; /user/bin/sshtest.ksh
    >> with sshtest.ksh holding:
    >> ssh -l remotelogin remoteserver "command" > result.log 2>&1
    >> Again, the resulting file was 0 bytes.
    >> Our sysadmin reckons the issue is to do with the script being called
    >> not having a tty assigned to it.

    >
    >
    > Try this:
    >
    > ssh -n -l remotelogin remoteserver "command" > result.log 2>&1

    Try first removing the "2>&1" and see what happen
    Next, replace "2>&1 with "> result-err.log"

    Or, I recommend the good approach (append):
    ssh -n -l remotelogin remoteserver "command" >> result.log 2>&1

    That way you can see output for more than one run and even spot when
    bad behavior in running your remote script.

    >
    >
    >
    >
    >
    >
    >



    --
    kind regards,
    Claudiu

+ Reply to Thread