• 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: Using cliclick with apple script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using cliclick with apple script


  • Subject: Re: Using cliclick with apple script
  • From: Christopher Stone <email@hidden>
  • Date: Mon, 25 Jul 2016 12:06:39 -0500

On Jul 24, 2016, at 19:55, Deivy Petrescu <email@hidden> wrote:
So here is a trick so you don’t have to look for the path of all apps

set path2app to (do shell script “whereis the app”

do shell script path2app + rest of command.


Hey Deivy,

`whereis` won't work, because it only looks in the standard directories.  (Unless the user foolishly installed a 3rd party app in one of them.)

/usr/bin:/bin:/usr/sbin:/sbin

`which` won't work either, because the AppleScript environment doesn't have anything but the basic path to search.

Again:

/usr/bin:/bin:/usr/sbin:/sbin

The most common directories for 3rd party apps are:

/usr/local/bin/

/opt/local/bin/

I also have some stuff in:

/opt/local/sbin

Hence my:

export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/bin:$PATH;

Which gives me pretty complete coverage in one line.



whereis -- locate programs

The whereis utility checks the standard binary directories for the specified programs, printing out the paths of any it finds.



which -- locate a program file in the user's path

The which utility takes a list of command names and searches the path for each executable file that would be run had these commands actually been invoked.



In a do shell script command it is necessary to provide the full path to each 3rd party app, or to adjust the $PATH as I did.

I much prefer to manage the $PATH once, instead of having to enter full paths for every 3rd party app I use in a shell script.  (I have a text-expansion for it in Typinator for convenience.)



Another option is loading your ~/.profile or ~/.bashrc files with the source command:

set shCMD to "
  source ~/.profile
  echo $PATH
"
set loginShellPath to do shell script shCMD

I prefer not to do this routinely, because of the potential for unintended side-effects – but that won't stop me when it's the best tool for the job.



It is also possible to call Bash as a log-in shell:

set shCMD to "echo 'echo $PATH' | bash -l"
do shell script shCMD



--
Best Regards,
Chris

 _______________________________________________
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

References: 
 >Using cliclick with apple script (From: "-dan d." <email@hidden>)
 >Re: Using cliclick with apple script (From: Deivy Petrescu <email@hidden>)

  • Prev by Date: Re: Using cliclick with apple script
  • Next by Date: Re: Console.app in Sierra
  • Previous by thread: Re: Using cliclick with apple script
  • Index(es):
    • Date
    • Thread