Howto pass an argument to alias of a script?
Hi,
I have a script that needs to run as root. I have an alias for it: alias my_script='su -c /path/path/path/my_script.sh \$*' Now, I've added to the script some options that can be given as parameters from the command line. for example: /path/path/path/my_script.sh 123 This works fine, but the alias doesnt pass that correctly... $ my_script 123 su: user 123 does not exist $ I've tryed all kind of combinations of "" '' `` but it didnt worked. Can someone please advise? Thanks! |
You need to change your alias
> alias my_script='su -c /path/path/path/my_script.sh \$*' to alias my_script='su -c /path/path/path/my_script.sh root' Read the man page for su. The first argument, if given, is the user to su to. The clue is in the error message > su: user 123 does not exist Your alias is passing 123 and su assumes that is the user. You don't need the \$*. You might do better to add the script that has to be run as root to those that sudo knows about, see visiudo, and use alias my_script="sudo my_script" instead. |
All times are GMT -5. The time now is 06:02 AM. |