 |
 |
scripting the alias command
|
 |
|
 |
|
Registered User
Join Date: Jan 2003
Location: New Brunswick, NJ
Status:
Offline
|
|
Anyone know why the below script doesn't work? (I'm not sure how I have the shell line (#!...), but I think I have that right.)
---------------------------
#!/bin/tsch/
alias new "pwd;date;clear"
alias list "clear;ls -F"
echo "test"
----------------------------
The two alias commands work fine outside the script, and when I run the script, the echo command prints out the string. Are there some commands that don't work inside a script?
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jan 2003
Location: Stuttgart, Germany
Status:
Offline
|
|
You have "/bin/tsch/" in your script, which is wrong. That should read "/bin/tcsh" (note the missing trailing slash).
But that isn't the culprit: each time you execute that script, a new shell gets started (the one you specified in the first line) and runs through the commands. After everything is said and done, the shell quits. Since those aliases are only setup for this shell, your script can't possibly work. If you want to setup aliases, you should do it in the appropriate init files.
BTW, the level of nested shells is stored in the "SHLVL" environment var.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status:
Offline
|
|
Originally posted by entrox:
You have "/bin/tsch/" in your script, which is wrong. That should read "/bin/tcsh" (note the missing trailing slash).
Is is the trailing slash or the mispelled shell name (tsch) that's causing the errors?
|
"In Nomine Patris, Et Fili, Et Spiritus Sancti"
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: May 2001
Status:
Offline
|
|
Either define your aliases in one of the init files like entrox told to have your aliases defined for every shell/terminal window you start, or use "source yourfilewithaliasdefinitions" to read them into your current shell only (won't need the #!/bin/tcsh line then).
-
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jan 2003
Location: Stuttgart, Germany
Status:
Offline
|
|
Originally posted by [APi]TheMan:
Is is the trailing slash or the mispelled shell name (tsch) that's causing the errors?
Neither one - That was just a tip for the future. I should have said it more clearly.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|