• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: User Name in OS X +
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: User Name in OS X +


  • Subject: Re: User Name in OS X +
  • From: John W Baxter <email@hidden>
  • Date: Thu, 24 Oct 2002 00:08:11 -0700

At 9:51 +0100 10/23/2002, John Delacour wrote:
>>We need to incorporate more obscure "stuff". Therefore, this additional
>>method:
>>
>>set cmd to "perl -e \"@p = getpwnam `whoami`;\""
>>set cmd to cmd & " -e 'print \"$p[6]\";'"
>>
>>do shell script cmd
>
>
>I can't work out why this doesn't work if I put the first bit in
>single quotes. Can you enlighten me please.

Putting the first "line" in single quotes precludes expansion of the
`whoami` stanza by the shell (I didn't tumble to the fact that it was the
shell doing that work until after I posted, although I instinctively used
the double quotes for that part).

And that rather glib paragraph glosses over the fact that perl is perfectly
willing to do `command` itself. So the reason the first command below
"works" and the second doesn't
[john@Zeus john]$perl -e 'print `whoami`'
john
[john@Zeus john]$perl -e 'print getpwnam `whoami`'
[john@Zeus john]$

isn't clear to me...why doesn't the second print the array contents? Running
$x = `whoami`;
print "$x\n";
inside a file certainly prints the result of whoami. Is this some
limitation of the -e environment????



Putting the second "line" in single quotes saved a whole lot of additional
backslashing, since I needed the double quotes in the print argument to get
the interpolation. I was too lazy to count \s. Unfortunately, the fonts I
use in Script Debugger and Eudora make "' or '" look like triple quotes
(which certainly aren't ASCII ;-)).

>
>
>I find this slightly less obscure:
>
>do shell script "perl -e '
>@p = getpwnam $ENV{USER} ;
>print $p[6] '"

I fully agree. Nicely done!
Your way is "better". But not so much fun. And I failed to see it.
TIMTOWTDI ;-) [1]

--John

[1] http://www.linux-france.org/prj/jargonf/T/TIMTOWTDI.html
(First Google "hit", but my early 1950s Jr High School French is "enough"
for this page.)
--
John Baxter email@hidden Port Ludlow, WA, USA
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: User Name in OS X + (From: "Jared ''Danger'' Earle" <email@hidden>)
 >Re: User Name in OS X + (From: John W Baxter <email@hidden>)
 >Re: User Name in OS X + (From: John Delacour <email@hidden>)

  • Prev by Date: Re: Recording in the script editor - Jaguar
  • Next by Date: Re: using apple script
  • Previous by thread: Re: User Name in OS X +
  • Next by thread: Re: User Name in OS X +
  • Index(es):
    • Date
    • Thread