• 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: System Events keystroke altering variable case
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: System Events keystroke altering variable case


  • Subject: Re: System Events keystroke altering variable case
  • From: Nigel Garvey via AppleScript-Users <email@hidden>
  • Date: Sat, 21 Sep 2019 09:53:44 +0100

mbox wrote on Thu, 19 Sep 2019 11:38:39 -0700:

>However, the command that gets passed to Terminal via System Events
looks
>like this:
>
>/usr/local/cpanel/3rdparty/perl/528/bin/perl -Mfile::Next -e 'print
>$File::Next::VERSION . "\n"'
>
>       Notice the first occurrence of module_name in that command - the word
>"file" gets lowercased, which breaks the command in the cli.  However
the
>strange part is that the 2nd occurrence of module_name remains properly
>capitalized.
>
>       What is System Events keystroke doing to that command?  Is there
another
>way to send this command?

>Mac OS 10.11.6
>
>tell application "Terminal"
>       activate
>
>       set module_name to the text returned of (display dialog "Enter the
module
>name" default answer "File::Next")
>
>       set _command to "/usr/local/cpanel/3rdparty/perl/528/bin/perl -M" &
>module_name & " -e 'print $" & module_name & "::VERSION . \"\\n\"'" as
>string
>
>       tell application "System Events"
>               keystroke _command
>               delay 0.1
>               key code 76
>       end tell
>
>end tell

Hi.

Your script types the expected text into Terminal on my 10.11.6 machine
and I doubt that System Events itself is doing anything to lower-case
that one character on yours. If you get that input consistently rather
than as a one-off, it really is a mystery.  :\

But you don't need to use System Events. You can use the 'do shell
script' command that David's given you, which would fit into your script
like this:

  -----
  set module_name to the text returned of (display dialog "Enter the module
name" default answer "File::Next")
  set _command to "/usr/local/cpanel/3rdparty/perl/528/bin/perl -M" &
module_name & " -e 'print $" & module_name & "::VERSION . \"\\n\"'"

  do shell script _command
  -----

… or you can use Terminal's own 'do script' command to execute the perl
code there:

  -----
  set module_name to the text returned of (display dialog "Enter the module
name" default answer "File::Next")
  set _command to "/usr/local/cpanel/3rdparty/perl/528/bin/perl -M" &
module_name & " -e 'print $" & module_name & "::VERSION . \"\\n\"'"

  tell application "Terminal"
    activate

    do script _command in window 1

  end tell
  -----

I don't have your third-party perl installation, so I can't test if the
perl stuff actually works.


NG
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: System Events keystroke altering variable case
      • From: mbox via AppleScript-Users <email@hidden>
  • Prev by Date: Re: System Events keystroke altering variable case
  • Next by Date: Re: System Events keystroke altering variable case
  • Previous by thread: Re: System Events keystroke altering variable case
  • Next by thread: Re: System Events keystroke altering variable case
  • Index(es):
    • Date
    • Thread