Re: Multiple modes? throught one connection

From: Mike Friedman (mikef_at_ack.Berkeley.EDU)
Date: 09/14/04

  • Next message: Edwin: "Re: mmap failure (???) causes my SSH installation to not work?"
    Date: Tue, 14 Sep 2004 09:31:49 -0700 (PDT)
    To: Tim Nelson <>

    On Mon, 13 Sep 2004 at 10:09 (+1000), Tim Nelson wrote:

    > Hi all. I often want to scp a file somewhere and then run it.
    > At the moment, I have to do an scp followed by an ssh (in a script) so I
    > need to type the password twice. Is there a way of linking the two
    > together somehow so that it will, through the one connection, trnasfer
    > the file, and then run the command? If so, is there somewhere that I
    > can find documentation on how to do this?


    Well, something like this might work (I haven't actually tried it):

      cat 'file' | ssh $Host 'cat > $File; chmod +x $File; $File'

    where '$File' is the name of the file on the remote system ('$Host').
    You'd be running three commands on the remote host, using only one ssh

       cat > $File [to retrieve the file sent from stdout on the local
                        host to stdin on the remote host]
       chmod +x $File [to make the remote file executible]
       $File [To execute the remote file itself]

    (Tweak the above to suit your particular situation).

    The main difference between using scp and 'ssh ... cat' to transfer a file
    is that the latter doesn't preserve permissions and dates. If you can live
    without the date preservation, this should not be a problem.


    Mike Friedman System and Network Security
    mikef@ack.Berkeley.EDU 2484 Shattuck Avenue
    1-510-642-1410 University of California at Berkeley

  • Next message: Edwin: "Re: mmap failure (???) causes my SSH installation to not work?"

    Relevant Pages

    • Re: Really need help on this one
      ... Is there a way to read the output of a particular command into ... Heres a better example using ssh. ... set timeout $timeout ... exec kill -9 $pid ...
    • Passing a redirect through a pipe
      ... I need to send a command over ssh to a remote system and have it's output redirected on that remote system: ... Any ideas on how to send the entire string to the program being executed and suppress the interpreter's redirection? ...
    • Re: OT: Hard disk mirror with Paragon on USB stick?
      ... at least two pages of intricate command line stuff. ... The password is only used when you want to backup to a remote machine ... via the network, using the ssh protocol. ... (e.g. with linux, ...
    • RE: midnight commander and ssh sftp
      ... midnight commander and ssh sftp ... which is displayed at the bottom of the MC panel. ... "Left file command options right" at the top of the MC ... MC SSH session with the remote host by hitting F10 key. ...
    • Re: sshd and ftpd
      ... ssh keys, so when you log in it doesn't ask for one. ... we want to be able to connect to our remote host without ... If you used the defaults supplied by the ssh-keygen command, ...