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: : 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:

set -x

for q in `cat itg4`

echo $q &>> log.txt

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

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,


This solved the issue

ssh $q "sed -i '/apache$/a sshd: : 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.