serial script communication to XY table

Two points.

  1. Is your table an RS232 system running at 9600 baud?
  2. The code
Serial.print("set_rack(1,40)");

Sends no new line control codes try:-

Serial.println("set_rack(1,40)");