# How to execute a robot file stored on remote machine, via a robot script?

**URL:** <https://forum.robotframework.org/t/how-to-execute-a-robot-file-stored-on-remote-machine-via-a-robot-script/4864>\
**Category:** Robot Framework\
**Created:** [25 October 2022 08:46 UTC](https://forum.robotframework.org/t/how-to-execute-a-robot-file-stored-on-remote-machine-via-a-robot-script/4864 "2022-10-25T08:46:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexeino](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/alexeino/32/1982_2.png) [@Alexeino](https://forum.robotframework.org/u/Alexeino)\
**Post date:** [25 October 2022 08:46 UTC](https://forum.robotframework.org/t/how-to-execute-a-robot-file-stored-on-remote-machine-via-a-robot-script/4864/1 "2022-10-25T08:46:42Z")

</div>

Hi,  
I want to automatically start django server on remote server. For that i have created a robotframework-djangolibrary robot file. Manually on remote server if i run this robot file, the server starts and works fine… BUT, i want to run this robot file from another robot file on my pc.  
So like remotely executing a robot file to start the django server.  
I run and get the log info in log.html, but after checking on remote machine, server isn’t running.

How to do that.

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [25 October 2022 10:43 UTC](https://forum.robotframework.org/t/how-to-execute-a-robot-file-stored-on-remote-machine-via-a-robot-script/4864/2 "2022-10-25T10:43:39Z")

</div>

Hi Alexeino,

While there are probably many ways this can be achieved, the most obvious that springs to mind for me is to use [SSHLibrary](https://github.com/robotframework/SSHLibrary), ssh to the machine where you have robotframework-djangolibrary working and run the robot command in the ssh session.

Dave.

---

<div class="post-metadata">

**Author:** ![Alexeino](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/alexeino/32/1982_2.png) [@Alexeino](https://forum.robotframework.org/u/Alexeino)\
**Post date:** [25 October 2022 11:11 UTC](https://forum.robotframework.org/t/how-to-execute-a-robot-file-stored-on-remote-machine-via-a-robot-script/4864/3 "2022-10-25T11:11:40Z")

</div>

Actually i have tried using SSH library, I am doing like…

```
${activate_env} C:/Users/lab/Documents/qxdm_wrapper/testenv/Scripts/activate
${start_django_server} robot C:/Users/lab/Documents/qxdm_wrapper/Server-Start.robot

```

and to execute

![image](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/9/9533e9cf5c6bba82098f7e653d4e13616c3b6736.png)

I am getting all green in the log.html also getting prompts for the django starting. BUT  
when checking the remote machine, Server isn’t running.  
I tried to run a simple python script for test, that didn’t work too man.  
Not sure what to do now.

---

<div class="post-metadata">

**Author:** ![Alexeino](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/alexeino/32/1982_2.png) [@Alexeino](https://forum.robotframework.org/u/Alexeino)\
**Post date:** [25 October 2022 11:12 UTC](https://forum.robotframework.org/t/how-to-execute-a-robot-file-stored-on-remote-machine-via-a-robot-script/4864/4 "2022-10-25T11:12:27Z")

</div>

btw, virtual environment is working just this robot script isn’t working.

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [25 October 2022 11:18 UTC](https://forum.robotframework.org/t/how-to-execute-a-robot-file-stored-on-remote-machine-via-a-robot-script/4864/5 "2022-10-25T11:18:17Z")

</div>

is the django environment getting stopped when the robot script exits on the remote machine or perhaps when the ssh session is closed all the processes under the ssh session are killed by the os?

- Perhaps try adding an `&` to the end of the `${start_django_server}` string
- if the django server can be started as a service instead of a process under the logged in ssh user then that might solve the process

Dave.

---

<div class="post-metadata">

**Author:** ![Alexeino](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/alexeino/32/1982_2.png) [@Alexeino](https://forum.robotframework.org/u/Alexeino)\
**Post date:** [25 October 2022 11:54 UTC](https://forum.robotframework.org/t/how-to-execute-a-robot-file-stored-on-remote-machine-via-a-robot-script/4864/6 "2022-10-25T11:54:15Z")

</div>

Since remote machine is Windows 10, can u suggest & alternative.

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [25 October 2022 12:10 UTC](https://forum.robotframework.org/t/how-to-execute-a-robot-file-stored-on-remote-machine-via-a-robot-script/4864/7 "2022-10-25T12:10:21Z")

</div>

Hi Alexeino,

# Option 1

On windows the command to start a service is:

```python
net start servicename 

```

Likewise to stop a service:

```python
net stop servicename 

```

When I searched for `django as a service windows` I found [Guguweb | Freelance developer and sysadmin](https://guguweb.com/2013/10/13/django-on-windows/)

But if you go that far you can probably just set the service to start automatically when windows starts on the VM, so you might not need to ssh into it to start django unless you are doing some django configuration first, so this might solve the original issue as well.

# Option 2

Another option is to use the windows `start` command (the windows equivalent of the `&` in \*nix environments

[Windows - Run process on background after closing cmd](https://superuser.com/questions/1069972/windows-run-process-on-background-after-closing-cmd)

Dave.
