Reputation: 836
I have a perl script that calls ps -ef
somewhere in the code. This script works in Linux but not in Solaris 5.10. My work around is to define an alias in my .profile:
ps_wrapper()
{
if [[ $1 = "-ef" ]]; then
/usr/ucb/ps auxwwww
else
/usr/ucb/ps $1
fi
}
alias ps=ps_wrapper
The problem is the alias is not available in the perl script. How can I get the script to see this alias?
Upvotes: 1
Views: 972
Reputation: 5721
ps_wrapper
is an alias known to your shell only, not to programs run underneath it. There are many ways to do what you are trying to accomplish here:
ps_wrapper
a script and put it on a PATH
POSIX::uname()
and form the ps
command line accordingly.ps
functionality (this one, maybe?).A couple more thoughts:
PS_PERSONALITY
environment variable can be used to set the ps
"personality."ps
adheres to POSIX/XPG/SUS, so by sticking to SUS semantics for the command line of ps
you can (in theory) get to the same command line and output on both systems.Upvotes: 5
Reputation: 2233
The shell alias won't help you with the perl script. Just move the workaround into the perl script, and you're done. If you don't want to add hacks to the script, use something like the perl module Proc::ProcessTable
, which (hopefully) works on your target platforms.
Upvotes: 1
Reputation: 64603
You can run bash -ic
if you want to use aliases from your .bashrc
.
Example:
$ grep hello ~/.bashrc
alias hello='echo hello'
$ bash -ic 'hello'
hello
Upvotes: 0