1

Hello I'm running a bash script to change a keyword on a text file but it is located @ my remote host (10.101.5.91), I tried with this sample code, but it does not change anything on that file, and also no errors to be shown.


changeConfig(){
    shopt -s globstar
    for file in $1
    do
            sed -i.bak 's/$2/$3/g' $file
    done
}

remoteFunction(){
    ssh [email protected] "`declare -f changeConfig`; changeConfig /var/www/file.txt
}

remoteFunction

Can anyone help me? Thankx.... :)

1

1 Answer 1

0

Following will change that keyword

#!/bin/bash
file='/path/on/remotehost/filename'      #PATH on remote host
ssh [email protected] "sed -i.bak "s/$2/$3/g" $file"    #Would work without password if ssh keys exchanges else will ask $ wait for password

Don't know what you are doing with $1 though.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.