Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
Operating System - Tru64 Unix
cancel
Showing results for 
Search instead for 
Did you mean: 

Setting alias in a script to be use on cmd line in ksh.

SOLVED
Go to solution
Jean-Pierre Denis
Valued Contributor

Setting alias in a script to be use on cmd line in ksh.

Hi,

I trying to set an alias that would be accessible from the command line in a shell script that would read the user input.

We need to manually monitor a backup that have the date in the log file. So instead of typing the long alias everyday I wrote a script that would set the alias.
The script would be run, the date entered and than the log file would be view with more.
We set bf to monitor files sytem backup and bo to monitor os backup.
Unfortunately, once the script is executed the alias do not work on the command line.

I receive the message: ksh: bf not found

I thought that using alias -x in the script would do the trick but unfortunately it does not work.

Any ideas or pointer would be great !


Here is the script:

#!/bin/ksh
clear
echo "Please enter the backupfs and backupos date (ddmmyy):"
read backupdate
# Create the alias for backupfs and backupos
alias -x bf='more /usr/it/custom/apps/backup/log/$backupdate.fslog'
alias -x bs='more /usr/it/custom/apps/backup/log/$backupdate.oslog'
echo "The alias were create"
echo "You can now issue bf and bo to monitor the backup"


Thanks,
JP
Open your Mind and use Open Source software...
2 REPLIES
Michael Schulte zur Sur
Honored Contributor
Solution

Re: Setting alias in a script to be use on cmd line in ksh.

if you call the script, it starts a new shell and after the script is finished, the alias is gone. Try . ./script

Michael
Jean-Pierre Denis
Valued Contributor

Re: Setting alias in a script to be use on cmd line in ksh.

Hi,

Thanks Micheal,
it's working if I call the script like this:

#. script

Thanks,
JP
Open your Mind and use Open Source software...