Hi all;
I have tried that way but it is not possible to change ipaddress via remote connection. 
You can change ipaddress via serial connection using that script because your connection doesn't closed during the operation.
But  if you try running  script via remote connection it won't work. I  think  it is the same thing as configuring it manually line by line.
Regards,
Burak.