I have a PHP script that calls a bash screen using exec and passes some variables via -f= and -d=
I am just wondering how can I access these in bash? For example I would call
scaleImage.sh -f=filename -d=directoryname
And I want to get those variables in scaleImage.sh
Inside the script you can access those strings via positional parameters. For example:
would output
You could use brace expansion or word splitting to break those apart.
See also the section on
getoptsinman bashfor another way to process options and arguments. Your command line would probably need to look like this if you usegetopts: