How to avoid escaping by accident in PERL using system()?

Posted by Brian on Stack Overflow See other posts from Stack Overflow or by Brian
Published on 2010-04-19T21:52:20Z Indexed on 2010/04/19 22:03 UTC
Read the original article Hit count: 200

Filed under:
|
|
|
|

I want to run some commands using the system() command, I do this way:

execute_command_error("trash-put '/home/$filename'");

Where execute_command_error will report if there was an error with whatever system command it ran. I know I could just unlink the file using Perl commands, but I want to delete stuff using trash-put as it's a type of recycling program.

My problem is that $filename will sometimes have apostrophes, quotes, and other weird characters in it that mess up the system command or Perl itself.

© Stack Overflow or respective owner

Related posts about linux

Related posts about bash