On 10/26/07, Jeff Pang <[EMAIL PROTECTED]> wrote:
> On 10/26/07, Sayed, Irfan (Irfan) <[EMAIL PROTECTED]> wrote:
> > Hi All,
> >
> > I am executing my $usr=qx("who am i"); to get the user id on unix
> > machine but it is giving error. sh: who am i: not found
> >
>
> Oops,it's `whoami` not `who am i` unless you have aliased it.

The who command (with arguments "am" and "i") first appeared in
Version 1 of AT&T UNIX.  It is part of POSIX and SUS.  The OP problem
is the quotes around the command that is causing the shell to try to
find a file named "who am i" (i.e. with spaces in the name of the
file).  The proper syntax is

my $usr = qx(who am i);

qx// is not a function; it is a quoting operator.  What goes inside it
should not be quoted unless you want the shell to see it quoted.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to