• 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: do shell script vs. do script with command
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: do shell script vs. do script with command


  • Subject: Re: do shell script vs. do script with command
  • From: Ed Stockly <email@hidden>
  • Date: Sun, 10 Feb 2008 12:24:30 -0800



So far I’m able to produce a viable result thru the terminal or calling the terminal with 
applescript, but for some reason the "do shell script" command does not produce the expected result.

Have a look at this item:
http://developer.apple.com/technotes/tn2002/tn2065.html

Q: My command works fine in Terminal, but when I try to use it in do shell script, I get an error about "command not found." What’s going on?

A: There are two possibilities. First, do shell script always uses /bin/sh to interpret your command, not your default shell, which Terminal uses. (To find out what your default shell is, say echo $SHELL in Terminal.) While some commands are the same between shells, others are not, and you may have used one of them. If you write your do shell script scripts in Terminal first, always use sh. You can start sh by typing /bin/sh; type exit to get back to your normal shell.

Second, when you use just a command name instead of a complete path, the shell uses a list of directories (known as your PATH) to try and find the complete path to the command. For security and portability reasons, do shell script ignores the configuration files that an interactive shell would read, so you don’t get the customizations you would have in Terminal. Use the full path to the command, for example, /sbin/ifconfig instead of just ifconfig. To find the full path in Terminal, say which command-name, for example, which ifconfig; to see the list of places do shell script will search, say do shell script "echo $PATH".

(This answer glosses over a few details — see Gory Details if you care.)

hth,

ES
=
 _______________________________________________
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: do shell script vs. do script with command
      • From: "Mark J. Reed" <email@hidden>
References: 
 >Re: A date IS a date (From: Jason Bruce <email@hidden>)
 >do shell script vs. do script with command (From: "EU - Luca Pozzato" <email@hidden>)

  • Prev by Date: Bring a window to front
  • Next by Date: Re: do shell script vs. do script with command
  • Previous by thread: Re: do shell script vs. do script with command
  • Next by thread: Re: do shell script vs. do script with command
  • Index(es):
    • Date
    • Thread