Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-17-2008, 04:21 PM   #1
LQ Newbie
Registered: Aug 2006
Posts: 4

Rep: Reputation: 0
Howto pass an argument to alias of a script?

I have a script that needs to run as root. I have an alias for it:
alias my_script='su -c /path/path/path/ \$*'

Now, I've added to the script some options that can be given as parameters from the command line. for example:
/path/path/path/ 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?
Old 02-17-2008, 07:14 PM   #2
LQ Newbie
Registered: Jul 2005
Posts: 3

Rep: Reputation: 0
You need to change your alias
> alias my_script='su -c /path/path/path/ \$*'

alias my_script='su -c /path/path/path/ 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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to pass argument to vpnc in F8 to acknowledge connection nolebrink Fedora 0 12-04-2007 11:56 AM
perl pass regex check as an argument lord-fu Programming 2 08-29-2007 03:55 PM
Pass argument between php scripts gandalf_the_grey Linux - Newbie 1 02-03-2006 03:53 PM
How to pass an argument to DHCPCD ? shazam75 Linux - Networking 3 02-27-2005 11:34 AM
PHP pass argument to shell script monzter Programming 2 08-14-2004 07:16 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:26 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration