Skip to content

FunctionManipulateFile

krimdomu edited this page Jan 24, 2011 · 1 revision

To transparently manipulate files you can require the (R)?ex Module Rex::Commands::File.

use Rex::Commands::File;

user "myuser";
password "mypass";

desc "Show the syslog";
task "syslog", "server1", "server2", sub {
   my $file_handle = file_read "/var/log/syslog";
   print $file_handle->read_all;
};

desc "Create a testfile";
task "testfile", "server1", "server2", sub {
   my $file_handle = file_write "/tmp/my-test-file.txt";
   $file_handle->write("This is my testfile\n");
   $file_handle->close;
};
Clone this wiki locally