UUOC - SSH & FTP - Unix

This is a discussion on UUOC - SSH & FTP - Unix ; server-a - -(ssh)- - > server-b - -(ftp only)- - > server-c | ^ | | - - - - - - - - - -(can't)- - - - - - - - - - - - - - - ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: UUOC - SSH & FTP

  1. UUOC - SSH & FTP

    server-a - -(ssh)- - > server-b - -(ftp only)- - > server-c
    |
    ^
    |
    |
    - - - - - - - - - -(can't)- - - - - - - - - - - - - - - - - - -
    Is there anything wrong with a UUOC approach below?
    cat << END_SSH >> /usr/bin/ssh
    blah
    blah
    ( cat << END_FTP > /usr/bin/ftp
    blah
    blah
    blah
    END_FTP
    )
    blah
    blah
    END_SSH
    Is there a more standard way? Here is another way:
    #!/bin/sh
    scp file from server-a to server-b
    ssh to server-b < ftp file from server-b to server-c
    FTP_END
    SSH_END
    clean up stuff
    But, the clean up stuff doesn't work. I've also seen single quotes
    around 'SSH_END' and 'FTP_END' but no single quotes around the end
    set
    of SSH_END and FTP_END. I don't know why? Is there a better way? A
    more solid way?

  2. Re: UUOC - SSH & FTP

    On Sep 14, 12:06*pm, John Doe wrote:
    > server-a - -(ssh)- - > server-b - -(ftp only)- - > server-c
    > * * *|
    > ^
    > * * *|
    > |
    > * * *- - - - - - - - - -(can't)- - - - - - - - - - - - - - - - - - -
    > Is there anything wrong with a UUOC approach below?
    > cat << END_SSH >> /usr/bin/ssh
    > blah
    > blah
    > ( cat << END_FTP > /usr/bin/ftp
    > *blah
    > *blah
    > *blah
    > *END_FTP
    > )
    > blah
    > blah
    > END_SSH
    > Is there a more standard way? *Here is another way:
    > #!/bin/sh
    > scp file from server-a to server-b
    > ssh to server-b < > ftp file from server-b to server-c
    > FTP_END
    > SSH_END
    > clean up stuff
    > But, the clean up stuff doesn't work. *I've also seen single quotes
    > around 'SSH_END' and 'FTP_END' but no single quotes around the end
    > set
    > of SSH_END and FTP_END. *I don't know why? *Is there a better way? *A
    > more solid way?


    I can think of a number of "solid" alternatives:

    1) Pipe the file to ssh, e.g.
    cat /pathA/fname | ssh B 'cat > /pathB/fname'

    2) Use scp.

    3) Use FTPS (or SFTP or HTTP or HTTPS or ...) via curl (http://
    curl.haxx.se/).

    4) Use rsync over ssh, e.g.
    export RSYNC_RSH=/usr/bin/ssh
    rsync -ltzv /pathA/fname B:/pathB/

    Given the right options, rsync can transfer individual files or entire
    directories
    - on the localhost,
    - or between the localhost and a remote host,
    - or between 2 remote hosts.


    There are also more "geeky" things you could try using netcat/socat
    and friends.

    ~Glynne

  3. Re: UUOC - SSH & FTP

    On Sep 15, 1:35*pm, "~Glynne" wrote:
    > On Sep 14, 12:06*pm, John Doe wrote:
    >
    >
    >
    > > server-a - -(ssh)- - > server-b - -(ftp only)- - > server-c
    > > * * *|
    > > ^
    > > * * *|
    > > |
    > > * * *- - - - - - - - - -(can't)- - - - - - - - - - - - - - - - - - -
    > > Is there anything wrong with a UUOC approach below?
    > > cat << END_SSH >> /usr/bin/ssh
    > > blah
    > > blah
    > > ( cat << END_FTP > /usr/bin/ftp
    > > *blah
    > > *blah
    > > *blah
    > > *END_FTP
    > > )
    > > blah
    > > blah
    > > END_SSH
    > > Is there a more standard way? *Here is another way:
    > > #!/bin/sh
    > > scp file from server-a to server-b
    > > ssh to server-b < > > ftp file from server-b to server-c
    > > FTP_END
    > > SSH_END
    > > clean up stuff
    > > But, the clean up stuff doesn't work. *I've also seen single quotes
    > > around 'SSH_END' and 'FTP_END' but no single quotes around the end
    > > set
    > > of SSH_END and FTP_END. *I don't know why? *Is there a better way? *A
    > > more solid way?

    >
    > I can think of a number of "solid" alternatives:
    >
    > 1) Pipe the file to ssh, e.g.
    > * *cat /pathA/fname | ssh B 'cat > /pathB/fname'
    >
    > 2) Use scp.
    >
    > 3) Use FTPS (or SFTP or HTTP or HTTPS or ...) via curl (http://
    > curl.haxx.se/).
    >
    > 4) Use rsync over ssh, e.g.
    > * *export RSYNC_RSH=/usr/bin/ssh
    > * *rsync -ltzv /pathA/fname *B:/pathB/
    >
    > Given the right options, rsync can transfer individual files or entire
    > directories
    > *- on the localhost,
    > *- or between the localhost and a remote host,
    > *- or between 2 remote hosts.
    >
    > There are also more "geeky" things you could try using netcat/socat
    > and friends.
    >
    > ~Glynne


    Here is what I wanted to do:

    ${UNIX_COMMANDS_LOCATION}/ssh -Tx ${SSH_USER}@${SSH_HOST} 2>/dev/null
    <<-EOA
    cd ${SSH_HOST_DIR};
    ${UNIX_COMMANDS_LOCATION}/ftp -v -n ${REMOTE_HOST} <<-EOB
    user ${REMOTE_USER} ${REMOTE_PWD}
    put ${FILE}
    quit
    EOB
    ${UNIX_COMMANDS_LOCATION}/rm -f ${SSH_HOST_DIR}/${FILE};
    EOA

    Scripts are interesting beasts. There is no use for the << operator
    so it is used for another way of getting input (STDIN). The <<
    operator is called a here-document. These are long pieces of input
    embedded in a script and sent to the STDIN of a command. A command
    can be executed on a remote host using ssh. A semicolon must separate
    commands.

    I don't know why I don't need a semicolon after the EOB tag? A "-" in
    front of the tag gets rid of tabs so the code looks cleaner.

    If you were to use it in a script you'd get a stty: : Invalid argument
    if you don't send STDERR to /dev/null. I thought it was pretty
    interesting to learn all this.

+ Reply to Thread