- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Why doesn't it work when I issued the command:...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2002 10:05 PM
04-24-2002 10:05 PM
Why doesn't it work when I issued the command: sh dir
I issued the following commands:
$ alias -x dir='ls -al'
$ sh dir
sh: dir: not found
Thanks!
Best Regards.,
May
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2002 10:31 PM
04-24-2002 10:31 PM
Re: Why doesn't it work when I issued the command: sh dir
Aliases are only known within the shell where they were defined - not in sub-shells!
Sorry,
Wodisch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2002 10:48 PM
04-24-2002 10:48 PM
Re: Why doesn't it work when I issued the command: sh dir
With the option -x, aliases are exported. And an exported alias is defined across the subshell environments.
I got the above words through 'man aliasa', but it doesn't work. I wondered why?
Best Regards.,
May
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2002 11:57 PM
04-24-2002 11:57 PM
Re: Why doesn't it work when I issued the command: sh dir
There are two issues here. What are you doing is creating an alias called dir and tyring to run it as script by doing sh dir.
Obiviously the shell will not find by any filename named dir and it will not execute.(Provided you have no file named dir in the directories defined in the PATH variable)
So you need to do
$ alias -x dir='ls -al'
$ sh
$ dir
The second issue is of the alias getting supported to the child shell. Well, here is an issue. When I checked the man pages for alias. It clearly mentions that when we use -x option alias gets exported to the child shell. But when I tried that it did not work.
Anybody in the forum who can help us.
- Sukant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2002 01:06 AM
04-25-2002 01:06 AM
Re: Why doesn't it work when I issued the command: sh dir
e.g.
$ alias -x myos="uname -sr"
$ myos
HP-UX B.11.00
$ alias -x|grep myos
myos='uname -sr'
$ sh -c "alias -x|grep myos"
$ echo $?
1
As far as I know the export of aliases or functions are advanced shell features which may only be available in shells such as Bash or sh-posix.
But on the other hand the regular sh on HP-UX claims to be of the latter type.
Hmm...
Thus, I would suggest to create a dot file
$HOME/.shrc
and put therein all your aliases you want to have available in every (not only login) shell.
Then in $HOME/.profile put
ENV=$HOME/.shrc
export ENV
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-25-2002 01:46 AM
04-25-2002 01:46 AM
Re: Why doesn't it work when I issued the command: sh dir
tyr
$ sh ./dir
or use full path name if it
is in your home directory then
try
$sh $HOME/dir
-Niraj