## Send URScript with Primary Interface

The Primary Interface protocol allows URScript script lines to be sent to the robot for execution.

Script can only be executed if you are connected to port `PrimaryClient` (default if not specified) or `SecondaryClient`.

You can send multiple script lines simultaneously.

```
set_digital_out(1, True)
```

You can also send script within a def function.

```
def primaryProgram():
  while (True):
    movej([0.9434381127910002, -1.3082063255028469, 2.2063341418137945, -2.6507188134210273, -1.081363649387086, 4.80585136204575], a=1.3962634015954636, v=1.0471975511965976)
    movej([0.9433155477260482, -1.014172108307441, 2.246293286726412, -2.9852336083709154, -1.0813798520591593, 4.805802742045307], a=1.3962634015954636, v=1.0471975511965976)
  end
end
```

When the script is received, the program is paused and your script is executed. There is no feedback on whether or not it has been executed.

To avoid stopping the main program, you can send script within a dry block, which defines a secondary program. The secondary program does not interrupt the main script and runs in parallel. However, it does not allow you to move the robot or write global variables.

Read UR documentation : https://www.universal-robots.com/articles/ur/programming/secondary-program/

```
sec secondaryProgram():
  set_digital_out(1, True)
end
```

In order for your robot to accept script execution, it must be **powered on** and in **Remote mode**, which can be selected using the switch located at the top right of Polyscope.

![switch remote](/universal-robots/switch-remote.png)

Also, be sure the robot is powered on to execute move instructions

The `Script.Send()` method of `PrimaryInterfaceClient` class is used to send the script to the robot.

**C# : PrimaryInterfaceScript**
```csharp
using UnderAutomation.UniversalRobots;

class PrimaryInterfaceScript
{
  static void Main(string[] args)
  {
    var robot = new UR();

    robot.Connect("192.168.0.1");

    /**/
    // Pause main program and execute script
    robot.PrimaryInterface.Script.Send("movej([-1.5,-1.5,-2,-0.5,1.8,0],a=1.4, v=1.05, t=0, r=0)");

    // Execute multiple commands
    robot.PrimaryInterface.Script.Send(@"
def primaryProgram():
  while (True):
    movej([0.9, -1.3, 2.2063341418137945, -2.7, -1.081363649387086, 4.8], a=1.4, v=1)
    movej([0.9, -1, 2.246293286726412, -2.9, -1.0813798520591593, 4.8], a=1.4, v=1)
  end
end");

    // Send Secondary program
    robot.PrimaryInterface.Script.Send(@"
sec secondaryProgram():
  set_digital_out(1, True)
end
");
    /**/
  }

}
```

Please refer to the **Script Manual** to see all the functions you can remotely call : <a href="https://www.universal-robots.com/download/?option=61790#section61549" target="_blank">Download PDF Script Manual</a>.

## Send urp program file

You can also send a local urp program file from your machine to the robot via SFTP : [read SFTP documentation](sftp-file-handling)

## Interpreter mode

It is also possible to send URScript lines via the "Interpreter Mode" protocol. : [read Interpreter Mode documentation](interpreter-mode)

## Try it with the Windows example

![PrimaryInterface](/universal-robots/WinformsScreenshots/PrimaryInterface.jpg)