Re: Scripting SSH connections

From: Darren Tucker (dtucker_at_zip.com.au)
Date: 05/17/04

  • Next message: Fernando Gomes Lima: "OpenSSH"
    Date: Mon, 17 May 2004 11:29:15 +1000
    To: Simon Burson <Simon.Burson@telecom.co.nz>
    
    

    Simon Burson wrote:
    > I would like to write a basic shell script (Linux - bash) that will make
    > an SSH connection to another machine, execute arbitrary commands, read
    > back the output and log off gracefully. I can pipe commands to ssh but
    > of course this isn't interactive and so decisions can't be made based on
    > output.

    Well, for one thing you can have the remote system do the logic, eg

    ssh localhost /bin/sh <<EOD
    if [ `uname` == "Linux" ]
    then
             echo yes
    else
             echo no
    fi
    EOD

    -- 
    Darren Tucker (dtucker at zip.com.au)
    GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4  37C9 C982 80C7 8FF4 FA69
         Good judgement comes with experience. Unfortunately, the experience
    usually comes from bad judgement.
    

  • Next message: Fernando Gomes Lima: "OpenSSH"

    Relevant Pages