"Sayed, Irfan (Irfan)" <[EMAIL PROTECTED]> writes:

> 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
>  
> Please guide how to resolve this

The problem is that you are trying to run the command "who am i" (with
spaces),  if you try that on the commandline you should get the same
error.

 $ "who am i"

Just remove the quotes:

 my $usr = qx(who am i);

And it should work.

But..., as allways with perl, TIMTOWTDI. You can get the user id
without having to run external programs.  See the variables $< and $>
in 'perldoc perlvar', and if you need the username, not just the
numeric user-id just use getpwuid to look it up.

 my $user = getpwuid $<;


--
 Christer


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


Reply via email to