- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How come my alias cannot work?
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
08-21-2001 07:48 PM
08-21-2001 07:48 PM
How come my alias cannot work?
alias psg='ps -el|grep \!*|grep -v grep'
But when I run "alias swapper", it says
grep: can't open swapper
But ps -ef|grep swapper can produce results as below,
# ps -ef|grep swapper
root 0 0 0 Apr 3 ? 1:28 swapper
root 26497 26069 2 11:51:42 ttyp3 0:00 grep swapper
Anybody know what's the reason?
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2001 08:13 PM
08-21-2001 08:13 PM
Re: How come my alias cannot work?
However, there is a much better and more reliable alias to use:
alias psg="UNIX95= /usr/bin/ps -C"
Now type the command: psg swapper
or better yet: psg sh
You will see that only the true basename of the command is located and the non-specific matching of grep is avoided. The UNIX95 setting is documented in the ps man page.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2001 08:15 PM
08-21-2001 08:15 PM
Re: How come my alias cannot work?
you could try something like this
alias psg='"ps -el|grep -v grep |grep "
once you source your .kshrc or your env file, you should be able to run
psg swapper
If you want to grep case insensitive you could modify your alias to
alias psg="ps -el |grep -v grep |grep "
Actually there is another easier way, if you are looking for a process with a known basename you could set up another alias
alias psf="UNIX95= ps -flC "
now running "psf swapper" would give you the same output.
For more information about UNIX95 (look at the manpage for ps)
-HTH
Ramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2001 10:29 PM
08-21-2001 10:29 PM
Re: How come my alias cannot work?
alias psg='ps -el|grep \!*|grep -v grep'
Anybody knows how to interpret "grep \!*" and show me an example?
One more puzzle, What does it mean by "UNIX95" in your command and how does it work?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2001 11:34 PM
08-21-2001 11:34 PM
Re: How come my alias cannot work?
UNIX95= ps -e -o "pcpu pid args" |sort -n
which will print percentage cpu of the processes in the reversed sorted order.
There are good explanations by Bill and other folks in this forum itself. You can try searching with UNIX95 search string.
Checkout manpage for ps to find out various options that can be used with XPG4 implementation of ps.
-Sri
PS: Please assign some points to the explanations you think are helpful to you. That will encourage people to participate more in the discussions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2001 11:49 PM
08-21-2001 11:49 PM
Re: How come my alias cannot work?
alias psg='ps -ef |grep \!* |grep -v grep|grep'
This is your command with an additional grep statement.
Your earlier command would be parsed as
ps -el|grep \!*|grep -v grep inetd
and obviously would result with the error message cannot open inetd.
And your grep \!* seems to get all the processes. When we specify \!, the shell will not try to match the files in the local directory.
However, as suggested by Bill and Ramesh, it is better to use XPG4 version of ps.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2001 12:27 AM
08-22-2001 12:27 AM
Re: How come my alias cannot work?
alias arguments only work in csh, i.e. (note there is no = sign):
# alias pgp 'ps -ef|grep \!*|grep -v grep'
# pgp swapper
root 0 0 0 Jul 1 ? 135:39 swapper
If you want to use arguments in ksh, you have to use shell functions, or fix your alias so that any argument you type works if it is tagged onto the end of the definition, i.e.
alias pgp="ps -ef|grep -v grep | grep "
Rgds, Robin.
btw, points assignments are a little overdue ;-)