0

I know that someone already ask for something similar but I haven't been able to use that commands in a remote host. I have the bash:

#!/bin/bash
IMSI="732111030120252"
ssh openbts@192.168.10.12 bash -c " '
sed -i '61,$d' /etc/asterisk/sip.conf   #erase the lines fron 61 to end of the file sip.conf
sed -i '288,$d' /etc/asterisk/extensions.conf
echo "[IMSI$IMSI].(sets)" >> /home/openbts/Desktop/Prueba  #Write that expression inside Prueba (Ignore .)

' "

However, he is considering $d and () like locals variables and not like part of the sed and echo commands.

I found that you can use \\\$d or all the line inside an echo, but they arent working.

Anyone have an idea?? Thank you

Barmar
  • 741,623
  • 53
  • 500
  • 612
  • Variables are expanded inside double quotes. Put the command in single quotes and they won't be expanded locally. – Barmar May 20 '14 at 21:45

1 Answers1

0

you need to escape the string properly, especially $ and ":

ssh openbts@192.168.10.12 "sed -i '61,\$d' /etc/asterisk/sip.conf;
  sed -i '288,\$d' /etc/asterisk/extensions.conf;
  echo \"[IMSI\$IMSI].(sets)\" >> /home/openbts/Desktop/Prueba;"
Pavel
  • 7,436
  • 2
  • 29
  • 42