The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Alias Help NetJones UNIX for Dummies Questions & Answers 1 03-16-2008 02:47 AM
How to get the alias,when we have the IP. preethgideon UNIX for Dummies Questions & Answers 2 07-24-2007 11:53 AM
alias klannon Filesystems, Disks and Memory 6 04-27-2006 05:36 AM
Alias sunhata Shell Programming and Scripting 3 01-29-2006 03:03 AM
alias sskb UNIX for Dummies Questions & Answers 2 12-17-2001 08:53 AM

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-31-2002
Registered User
 

Join Date: Jan 2002
Location: Buffalo, NY
Posts: 2
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
alias creation

I am trying to set up an alias called "fire" that will allow me to pass an argument(s) along with the command.

#fire program1 restart

the fire alias should resolve to "/etc/rc.d/init.d/" and then stick the "program1" immediatly after the trailing slash so it appears as one command with one argument.

#/etc/rc.d/init.d/program1 restart

I would like to put this alias in my .cshrc file but can't get the alias working?

Thanks.
Forum Sponsor
  #2 (permalink)  
Old 01-31-2002
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,240
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Try:
alias fire '/etc/rc.d/init.d/\!:*'
  #3 (permalink)  
Old 01-31-2002
Registered User
 

Join Date: Jan 2002
Location: Buffalo, NY
Posts: 2
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Thumbs down

Thanks for the reply; however, it still gives an error

bash: /etc/rc.d/init.d/!:*: No such file or directory

My alias declaration looks like this...

alias start='/etc/rc.d/init.d/\!:*'

I run it by this command...

# start app1 restart
  #4 (permalink)  
Old 01-31-2002
thehoghunter
Guest
 

Posts: n/a
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Perderabo gave a correct answer for what you asked and it does work....in csh. You wrote you wanted to add it to .cshrc.

If your account isn't using csh, then it may not work - please insure which shell you need the alias set up in as each could/would be different from csh.

(You may also want to put what OS you are using.)
  #5 (permalink)  
Old 01-31-2002
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,240
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
*rofl* In your first post you didn't say which shell you were using, however you did mention putting the alias in .cshrc which is a standard startup file for csh. I therefore jumped to the conclusion that you are using csh or tcsh or some other csh clone. Putting bash aliases in .cshrc is rather unusual, but I guess you have customized your environment. Oh well, most people freak when they see my environment too...

bash has wimpy aliases and you can't constuct a bash alias to do this. You will need to use a function, like this:
fire() { /etc/rc.d/init.d/$* ; }

Most bash users would add that .bash_profile or .bash_rc or something like that. But, ummm, I'll leave it up to you where to install this.
Google UNIX.COM
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:47 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101