in reply to Re: system, pipes, shell, quoting
in thread system, pipes, shell, quoting
This way, all of your arguments are passed to the shell within single quotes, nothing is escaped or interpreted in any special way, and each arguement will be a single word even if there are spaces in the argument. Of course, you have to be using a shell that works this way or similiar, and if there is a possibility that the $argument will contain single quotes, you have to account for that with something like this:... my $argument = something; my $argument2 = somthing else; $argument = "'".$argument."'"; #surround in quotes $argument2 = "'".$argument2."'"; #surround in quotes $exec_string = "$program $argument $argument2"; system("$exec_string"); ...
before further processing. This all works for the bash shell and should me easily modifiable for most others.... $argument=~s/'/'"'"'/g; ...
|
|---|