Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to write a utility script that defines certain aliases.
My SHELL is tcsh (can't change that).

I tried the following

#!/bin/tcsh
alias log 'less ~/logs/log.date '+%Y%m%d'''

Then I run it like this:

> ./myscript
> log

The output I get is: log: Command not found.

Naturally if I run it like this:
> source myscript
> log

Everything is fine.

Any way to do it without specifying source ...?

share|improve this question
    
Did you put the alias in your ~/.cshrc file? –  qweet Jul 11 '12 at 8:32
    
@qweet - That is not my goal - I wanted something dynamic. –  RonK Jul 11 '12 at 11:14
add comment

1 Answer

up vote 5 down vote accepted

You can't. By running your script you execute a new shell. Aliases will not be seen by the parent process.

The only way as pointed out is using source so that the current shell processes your script file (without starting a new process).

share|improve this answer
    
Thank you - that is what I thought - I'll add an alias to my .alias that will to source myscript - I wanted something easy that can be shared by all team members - an alias will do it. –  RonK Jul 11 '12 at 11:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.