企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# B.6 AvailableTask Available Task tests if a resource/file is set and sets a certain property to a certain value if it exists. Here, `AvailableTask` first checks for the existence of either file or directory named `test.txt` in `/tmp`. Then, it checks for the directory `foo` in `/home` and then for the file or directory `bar` in `/home/foo`. If `/tmp/test.txt` is found, the property `test_txt_exists` is set to `"Yes"`, if `/home/foo` is found and a directory, `properties.yetanother` is set to `"true"` (default). If `/home/foo/bar` exists, `AvailableTask` will set `foo.bar` to `"Well, yes"`. And last it checks if extension `foo` is loaded, so the property `foo.ext.loaded` is set to `"true"` (default). **NB:** the Available task can also be used as a condition, see [conditions](ch05s08.html "5.8 Conditions"). Table B.8:聽Attributes NameTypeDescriptionDefaultRequired`property``String`Name of the property that is to be set.n/aYes`value``String`The value the property is to be set to.`"true"`No`file``String`File/directory to check existence.n/aYes (or `resource` or `extension`)`resource``String`Path of the resource to look for.n/aYes (or `file` or `extension`)`extension``String`Name of the extension to look for.n/aYes (or `file` or `resource`)`type``String` (file|dir)Determines if `AvailableTask` should look for a file or a directory at the position set by `file`. If empty, it checks for either file or directory.n/aNo`filepath``String`The path to use when looking up `file`.n/aNo`followSymlinks``Boolean`Whether to dereference symbolic links when looking up `file`.`false`No B.6.1 Examples ``` <available file="/tmp/test.txt" property="test_txt_exists" value="Yes"/> <available file="/home/foo" type="dir" property="properties.yetanother" /> <available file="/home/foo/bar" property="foo.bar" value="Well, yes" /> ```