Setting aliases


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Setting aliases
# 1  
Old 04-15-2009
Setting aliases

How come if I set an alias as such:
Code:
alias dt 'date "+%Y-%m-%d %H:%M:%S"'

it will work as intended, ie the command 'dt' does prompt the date and time, but not when invoked through a script as such:
Code:
#!/bin/sh
alias dt 'date "+%Y-%m-%d %H:%M:%S"'

The OS is FreeBSD 7.1.

Thanks in advance
# 2  
Old 04-15-2009
Code:
. myShellScript.sh

# 3  
Old 04-15-2009
Thank you for your prompt answer. The response is "permission denied" irrespective of whether as regular user or root. There are many other lines in the script and the script is commonly invoked as follows:
Code:
./myscript.sh

# 4  
Old 04-15-2009
Code:
. ./myscript.sh

# 5  
Old 05-05-2009
I currently have the following in the script, which seems to work:
Code:
echo 'alias dt' "'"'date "+%Y-%m-%d %H:%M:%S"'"'"

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Issues with setting Aliases

Hi, I have set alias rm='rm -i' and i m able to see that in the list of aliases. however, when i fire the rm command the '-i' interactive flag does not seem to kick in. I login to a free online terminal and then i say bash to set the bash profile. Join Here is the output... (27 Replies)
Discussion started by: mohtashims
27 Replies

2. Solaris

Is there a difference between setting a user as nologin and setting it as a role?

Trying to figure out the best method of security for oracle user accounts. In Solaris 10 they are set as regular users but have nologin set forcing the dev's to login as themselves and then su to the oracle users. In Solaris11 we have the option of making it a role because RBAC is enabled but... (1 Reply)
Discussion started by: os2mac
1 Replies

3. UNIX for Dummies Questions & Answers

Unsetting aliases

Within a session we have created some aliases. How to unset all the aliases in the session or specific alias? (1 Reply)
Discussion started by: pandeesh
1 Replies

4. HP-UX

[Solved] Aliases in HP-UX

Hi folks, How can I make an alias in HP-UX? I've tried to add something just like this bye='exit' (as example), the system accepted but when I write bye in the terminal its return with invalid command. When I make such alias in RedHat or Fedora the system accept it right there, what is the... (7 Replies)
Discussion started by: leo_ultra_leo
7 Replies

5. UNIX for Dummies Questions & Answers

Problem with aliases

I work on a MAC. And i have the need to connect to various servers on a daily basis. So I use aliases in bash shell. The aliases work fine in bash shell. But they dont work with tcsh. Can anybody clarify what might be wrong? (1 Reply)
Discussion started by: newprofile
1 Replies

6. Shell Programming and Scripting

etc aliases

Hello: i have several server with own etc aliases. right now i want to combine it all into a general etc aliases in a new freebsd server. cause it consist hundred thousand of record user inside how to make a shell script to combine it or configure it. all etc aliases record example: ... (0 Replies)
Discussion started by: peterLfs
0 Replies

7. UNIX for Dummies Questions & Answers

man aliases

Can any one show me how to create an alias account that silently copies local emails to the administrator (root) using a linux cmd line or GUI? The answer needs to be very simplly explained at this stage, as I am new to the command prompt...expecialy in linux. thanks heaps guys Pipa:) I... (2 Replies)
Discussion started by: Pipa
2 Replies

8. Programming

retireving ip aliases

hi, i created some IP aliases, but the only way i can c the aliases is using ifconfgi.. is there any other system command i can use to access the aliased ip list? i tried gng to /proc/net/aliases.. but i don`t have aliases in /proc/net . Also.. is there ayway i can retireve it using... (2 Replies)
Discussion started by: caltiger
2 Replies

9. UNIX for Dummies Questions & Answers

aliases

Is there a way to view what aliases are running on a given session? (1 Reply)
Discussion started by: BG_JrAdmin
1 Replies

10. Programming

aliases

Hi. I have a C program that is using the **environ pointer and I am trying to set up aliases for a system("/bin/ksh") call. This works for other environment variables but not for the aliases. Does anyone know if this can be done? Thanks ahead of time. (1 Reply)
Discussion started by: mluey61
1 Replies
Login or Register to Ask a Question