# Revision history [back]

### get list of directory subdirectories

Hi! I am trying to create a custom fact that returns the list of subdirectories within a subdirectory, if the subdirectory exists. For example, if the computer has /data/files, I need to obtain all the subdirectories inside it (/data/files/one, /data/files/two, /data/files/three), without the prefix path (so just (one two three).

I tried to write a custom fact but I am failing woefully,

Facter.add(:toukdockerdirs) do
result = ''
setcode do
if File.directory? '/dataspace/apps' do |str|
Facter::Util::Resolution.exec('/bin/ls -d /dataspace/apps/*')
result += str
end
end
end


end

Please what am I doing wrong and how can I make it better?

### get list of directory subdirectories

Hi! I am trying to create a custom fact that returns the list of subdirectories within a subdirectory, if the subdirectory exists. For example, if the computer has /data/files, I need to obtain all the subdirectories inside it (/data/files/one, /data/files/two, /data/files/three), without the prefix path (so just (one two three).

I tried to write a custom fact but I am failing woefully,

Facter.add(:toukdockerdirs) Facter.add(:datasubdirs) do
result = ''
setcode do
if File.directory? '/dataspace/apps' '/data/files' do |str|
Facter::Util::Resolution.exec('/bin/ls -d /dataspace/apps/*')
/data/files/*')
result += str
end
end
end


end

Please what am I doing wrong and how can I make it better?

### get list of directory subdirectories

Hi! I am trying to create a custom fact that returns the list of subdirectories within a subdirectory, if the subdirectory exists. For example, if the computer has /data/files, I need to obtain all the subdirectories inside it (/data/files/one, /data/files/two, /data/files/three), without the prefix path (so just (one two three).

I tried to write a custom fact but I am failing woefully,

Facter.add(:datasubdirs) do
result = ''
setcode do
if File.directory? '/data/files' do |str|
Facter::Util::Resolution.exec('/bin/ls -d /data/files/*')
/data/files/')
result += str
end
end
end


end

Please what am I doing wrong and how can I make it better?