0

I'm trying to add an ip adress on a list of hosts.

when I do this directly on the host it works:

sed i- /apache$/a sshd: 192.168.2.2 : allow' /etc/hosts.allow

But when I do this by script bash it writes in log.txt file:

./hostsallow.sh: line 11: sed -i /apache$/a: No such file or directory

here is the script:

#!/bin/bash
set -x

for q in `cat itg4`
do

echo $q &>> log.txt


ssh $q -n 'sed -i '/apache$/a sshd: 192.168.2.2 : allow' /etc/hosts.allow' &>> log.txt
done

the set -x gives on screen:

Pseudo-terminal will not be allocated because stdin is not a terminal.

Please can you help me?

Best regards,

1
1

This solved the issue

ssh $q "sed -i '/apache$/a sshd: 192.168.2.2 : allow' /etc/hosts.allow" &>> log.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.