Change through ssh through ssh



  • Through a ssh connection, a scruple must be carried out in a remote car. I can't handle sed. Or more precisely how it interacts with transmitted variables

    Example:

    #!/bin/bash
    #
    A=«java.extended.prop=-XX\:NewSize\=1024m -XX\:MaxNewSize\=1024m -XX\:PretenureSizeThreshold\=10m»
    

    ssh root@10.2.200.172 "
    B=$(echo $A | cut -d «=» -f 2-)
    touch /tmp/test.txt echo «java.extended» > /tmp/test.txt
    cat /tmp/test.txt
    sed -i '/java/a $B' /tmp/test.txt
    cat /tmp/test.txt "

    The outcome will be:

    java.extended
    $B

    How is it right to hand over the sed variable from a remote car to get the tape I need?

    What should be:

    java.extended
    -XX: NewSize=1024m -XX:MaxNewSize=1024m -XX:PretenureSizeThreshold=10m



  • You can record the results of the violin/command in a remote car to the local variable, and then process the result in a local car.

    FIRST_VAR="very long text"
    SECOND_VAR=`ssh username@servername "some_remote_script $FIRST_VAR ...."`
    echo $SECOND_VAR | sed ...
    

    Try that.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2