You can accept command line arguments to a script, and then pass them to the system call.
This is not a good idea, however. If you do this, run perl in taint mode. Secondly, if you choose to do this, validate the variables before you pass them as args to the system call. Here is why:
If you have a progam, say, "foo". and when I run foo, it will use a system() call to run command "bar". When I call your program I could, if I'm running as root, just pass "| rm -fR /*" at the command line, and after bar ran I would erase the hard drive.
When a perl script is executed, there are several different ways that you can accept arguments from the user. The array @ARGV contains all arguments passed to the command line, seperated by whitespace.
If you need to use flags, and then a value, then you would use GetOpt::Long.
This will parse the args into a hash, with key/value pairs that contain the flag and the value.
You can then use these variables as you please.
Last edited by PenguinPwrdBox; 11-16-2005 at 08:01 PM.