Skip to content
krimdomu edited this page Feb 19, 2011 · 2 revisions

To transparently manage your Filesystem you can require the (R)?ex Module Rex::Commands::Fs.

Right now you can do the following things:

  • Create a directory

  • Remove an (empty) directory

  • Unlink files

  • List files in a directory

use Rex::Commands::Fs;

user "myuser";
password "mypass";

desc "create temp directory";
task "my-own-tmp", "server1", "server2", sub {
   mkdir "/tmp/my-very-own-tmp";
};

desc "remove temp directory";
task "rm-my-own-tmp", "server1", "server2", sub {
   rmdir "/tmp/my-very-own-tmp";
};

desc "remove /etc/passwd";
task "harhar", "server1", "server2", sub {
   print "You don't want to do this!\n";
   unlink "/etc/passwd";
};

desc "list files in /etc";
task "lsetc", "server1", "server2", sub {
   for my $file (list_files("/etc")) {
      print "> $file\n";
   }
};
Clone this wiki locally