# Using mender client as a trigger or a signal to execute a script

**URL:** <https://hub.mender.io/t/using-mender-client-as-a-trigger-or-a-signal-to-execute-a-script/6640>\
**Category:** General Discussions\
**Tags:** mender-client\
**Created:** [March 19, 2024, 10:28am UTC](https://hub.mender.io/t/using-mender-client-as-a-trigger-or-a-signal-to-execute-a-script/6640 "2024-03-19T10:28:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Utsav\_Shah](https://avatars.discourse-cdn.com/v4/letter/u/3ab097/32.png) [@Utsav\_Shah](https://hub.mender.io/u/Utsav_Shah)\
**Post date:** [March 19, 2024, 10:28am UTC](https://hub.mender.io/t/using-mender-client-as-a-trigger-or-a-signal-to-execute-a-script/6640/1 "2024-03-19T10:28:01Z")

</div>

I am currently working on a IoT gateway project that requires mender to do an OS update. The mender client is successfully installed and running on the gateway. What I want to do is run a custom script that will be triggered when mender client starts the OS update process when initiated from the dashboard.  
The sequence of actions could be something as follows:  
1.Deploy the OS update from mender dashboard  
2.Mender client communicates with mender server and checks that an OS update has been triggered.(this is my assumption of how it would run)  
3. Once mender client starts downloading the OS update artifact from mender server, it can trigger my custom script to run.

Is this possible to do on the gateway system? Are there any configuration or script files that are automatically run by mender client that I can modify such that while executing, it also calls my script to run?

Any inputs to this would be very helpful!

---

<div class="post-metadata">

**Author:** ![TheYoctoJester](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/theyoctojester/32/1444_2.png) [@TheYoctoJester](https://hub.mender.io/u/TheYoctoJester)\
**Post date:** [March 19, 2024, 10:59am UTC](https://hub.mender.io/t/using-mender-client-as-a-trigger-or-a-signal-to-execute-a-script/6640/2 "2024-03-19T10:59:24Z")

</div>

Hi @Utsav_Shah,

The state scripts can do exactly that. For the given description, you probably want to use the `Download` state. More details in the documentation at [State scripts | Mender documentation](https://docs.mender.io/artifact-creation/state-scripts#root-filesystem-and-artifact-scripts)

Greets,  
Josef

---

<div class="post-metadata">

**Author:** ![Utsav\_Shah](https://avatars.discourse-cdn.com/v4/letter/u/3ab097/32.png) [@Utsav\_Shah](https://hub.mender.io/u/Utsav_Shah)\
**Post date:** [March 28, 2024, 7:20am UTC](https://hub.mender.io/t/using-mender-client-as-a-trigger-or-a-signal-to-execute-a-script/6640/3 "2024-03-28T07:20:15Z")

</div>

Understood! Thank you for the info.  
I am currently running mender client on a Ubuntu server version 20.04. As per the document, it says that you can find scripts for Download state in **/etc/mender/scripts**.

In my system I could not find any scripts for the download state :  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/mender/original/2X/f/f4e1bc653e649740f646e97ffc0e70b58bd6f0c7.png)

Is there any other location where I can find those scripts?
