# iRule to read dynamic file in /tmp/ location

**URL:** <https://community.f5.com/t/irule-to-read-dynamic-file-in-tmp-location/1742>\
**Category:** Technical Forums\
**Tags:** irules, big-ip-access-policy-manager-apm, devops, security, application-delivery, file\
**Created:** [June 10, 2015, 4:34pm UTC](https://community.f5.com/t/irule-to-read-dynamic-file-in-tmp-location/1742 "2015-06-10T16:34:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jim\_Araujo\_1061](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@Jim\_Araujo\_1061](https://community.f5.com/u/Jim_Araujo_1061)\
**Post date:** [June 10, 2015, 4:34pm UTC](https://community.f5.com/t/irule-to-read-dynamic-file-in-tmp-location/1742/1 "2015-06-10T16:34:59Z")

</div>

Hi All, I’ve been trying to figure out if there is a way for an iRule to read from a file located in the /tmp/ directory on itself (LTM). The reason for this is I have a script running as a cronjob on the LTM to generate a unique string that I want to be able to manipulate and use in this iRule.

So in summary, can an irule read from a location on the itself(LTM) and store it as a string?

Thanks!

---

<div class="post-metadata">

**Author:** ![Michael\_Jenkins](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@Michael\_Jenkins](https://community.f5.com/u/Michael_Jenkins)\
**Post date:** [June 10, 2015, 5:04pm UTC](https://community.f5.com/t/irule-to-read-dynamic-file-in-tmp-location/1742/2 "2015-06-10T17:04:37Z")

</div>

Maybe someone can correct me if I’m wrong, but I’m pretty sure you can’t access the file system through an iRule.

As a possible way around that, you could set your cron job up to run a

```tcl
tmsh

```

command to update a

```tcl
data group

```

with your unique string. Then your iRule could read the string from the data group (I don’t believe you can update a data group record within an iRule though).

Hope this helps.

---

<div class="post-metadata">

**Author:** ![Hannes\_Rapp](https://avatars.discourse-cdn.com/v4/letter/h/779978/32.png) [@Hannes\_Rapp](https://community.f5.com/u/Hannes_Rapp)\
**Post date:** [June 10, 2015, 5:04pm UTC](https://community.f5.com/t/irule-to-read-dynamic-file-in-tmp-location/1742/3 "2015-06-10T17:04:47Z")

</div>

Unfortunately, not possible at this point. TMOS and the underlying RHEL are kept separated on purpose. You can circumvent that since v11.4 (iCall). iRule calls the iCall → iCall calls the TCL script → TCL script interacts with the file in /tmp/ location. Can be a bit complicated if it’s your first time doing a workaround like this, suggest to decomission your idea 🙂

---

<div class="post-metadata">

**Author:** ![Michael\_Jenkins](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@Michael\_Jenkins](https://community.f5.com/u/Michael_Jenkins)\
**Post date:** [June 11, 2015, 3:12pm UTC](https://community.f5.com/t/irule-to-read-dynamic-file-in-tmp-location/1742/4 "2015-06-11T15:12:15Z")

</div>

Tried to update my original answer, but it wouldn’t save, so here’s the idea.

You can use the following commands to work with data groups from the command line:

```tcl
CREATE
tmsh create / ltm data-group internal TEST_DATA_GROUP records add { MyKey { data MyValue } } type string

 MODIFY
tmsh modify / ltm data-group internal TEST_DATA_GROUP records replace-all-with { MyKey2 { data MyValue2 } }

 LIST
tmsh list / ltm data-group internal TEST_DATA_GROUP

```

In your iRule, you could grab the value like this

```tcl
set myval [class match -value "MyKey" equals TEST_DATA_GROUP]

```
