[rrd-users] Problem with CDEFs, and question about PRINT

Sam Umbach sumbach at gmail.com
Tue Apr 24 01:55:55 CEST 2007


David,

1) Instead of calling system() directly, save the command to a string
first and print it out.  That will help you check if there are
problems with quotes or other shell special characters.  If you're
still having a problem, post the command command line (with variables
substituted) and we can help diagnose the issue.

2) I highly discourage using the shell to parse commands in this way
(system() calls the shell if you give it a single string argument).
In the best case, it just creates confusion; in the worst case it
results in a security hole (if this is part of a CGI script, a remote
user may be able to execute arbitrary commands on your system as the
apache user).  Instead, use the multi-argument form of system(); this
calls fork() and exec() and avoids the shell entirely.

3) If you want to capture STDOUT and/or STDERR from a command, have a
look at the following references.  Backticks allow you to easily
capture STDOUT, but the shell will parse the command.  Consider
instead:

http://search.cpan.org/~nwclark/perl-5.8.8/pod/perlipc.pod#Safe_Pipe_Opens
http://search.cpan.org/~dgold/Proc-Reliable-1.16/Reliable.pm
http://search.cpan.org/~nwclark/perl-5.8.8/lib/IPC/Open2.pm
http://search.cpan.org/~nwclark/perl-5.8.8/lib/IPC/Open3.pm

The first reference will probably be sufficient for your needs, but
Proc::Reliable or IPC::Open2 may be easier to use.

-Sam



More information about the rrd-users mailing list