• 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 info
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: System info


  • Subject: Re: System info
  • From: Ron Hunsinger <email@hidden>
  • Date: Fri, 25 Apr 2014 17:12:06 -0700

On Apr 25, 2014, at 8:27 AM, Iurista GmbH <email@hidden> wrote:

> Hi
>
> Sometimes, some of my scripts are executing far too slow (10 to 20 seconds...). I figured out that this were all scripts calling for "system info", and that in most cases, it seemed to be the item "IPv4 address" resulting in a missing value statement. At first sight, it appeared that this only happened when I'm not connected to the internet, but now it starts also be slow while connected. Unfortunately I need some of the informations from system info quite very often, and some of such scripts are part of my QuicKeys shortcuts (which in turn naturally seems to hang).
> How can I fix that problem?

If I understand your situation correctly:

a) Your script needs some piece of information
b) That information is part of what 'system info' returns
c) 'system info' ALSO returns your IP address, but that's not the information you're looking for
d) Sometimes, 'system info' takes a long time trying to get your IP address.

'system info' won't tell you anything until it knows everything, so if it has to wait for any piece of data, so do you. Which is a real nuisance if the info it's hanging on (IP address, in this case) is info you don't care about. You still have to wait.

This is an instance of a general problem I see again and again in scripts. Not only in AppleScripts, but in shell scripts as well. The script writer invokes a tool that will provide gobs and gobs of information, then uses 'grep' or 'sed' or 'awk' to whittle away all but the one line of information they were looking for. I once saw a shell script that, to determine whether a file with a given name existed, used 'ls' to get a complete listing of all files in the parent directory and piped that into 'grep' to see if the given name was in the list. My protestations that the shell could already do that efficiently using the builtin [[ -e filename ]] test, without having to spawn two subordinate processes and pipe gobs of data between them, fell on deaf ears. That's an extreme case; more often you see it as invoking some information source that will tell you everything it knows if called without parameters, and then filtering its voluminous output through grep.

The solution, of course, is: ask ONLY for the data you're interested in. It's easy (but not efficient) to throw away useless information from an encyclopedic response, but it's a whole lot more efficient to avoid generating that useless information in the first place.

So, what piece(s) of information DO you need in your script(s). See if there's a more focused way to ask for it. After all, 'system info' has to get all that data from somewhere. Why not skip the middleman, and go straight to the source yourself?

-Ron Hunsinger


 _______________________________________________
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 info
      • From: Iurista GmbH <email@hidden>
References: 
 >System info (From: Iurista GmbH <email@hidden>)

  • Prev by Date: Re: System info
  • Next by Date: Re: XMLlib library
  • Previous by thread: Re: System info
  • Next by thread: Re: System info
  • Index(es):
    • Date
    • Thread