• 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: Shell script problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shell script problem


  • Subject: Re: Shell script problem
  • From: Christopher Nebel <email@hidden>
  • Date: Mon, 12 Dec 2005 12:02:46 -0800

On Dec 11, 2005, at 11:39 AM, deivy petrescu wrote:

On Dec 11, 2005, at 14:03, Ronald 'Warui' Becher wrote:

Manfred M. Strasser schrieb:

ls -l -S -F cd /Users/xyz/Desktop/oneFolder/
In the Terminal I get a correct result ... But using this in an AppleScript ...
do shell script "ls -l -S -F cd " & "/Users/xyz/Desktop/xyz/"
returns an error: "No such directory ..."
What's the bug?

Hello Manfred,

I somehow can't find one and your snippet works with me ... yet only with existing directories of course ;-)
But I never get an error like the one you describe. If I want to list a non existing directory the output consists only of double quotes.


Greetings
Ronald

There is no bug! It does not work in either terminal or shell script.
The difference is that in terminal you get a error and then you the second command


ls -l -S -F /Users/xyz/Desktop/xyz/

gets executed. The script exits with an error as soon as you try to

ls cd.

Since there is no cd directory you get an error.

Close, but not quite. There's only one command there -- "ls -l -S -F cd /Users/xyz/blah". What happens in Terminal is that first ls tries to list "cd" and fails because there's no such directory (and it says so, if you look), but then goes on to successfully list the other directory, and then returns a status of 1 because one of the arguments failed (though you can't see that in Terminal without explicitly asking for it).


The difference is that in Terminal, you get to see all the output even though the command failed, but AppleScript throws away the output if there was an error, which there was. Go read <http:// developer.apple.com/technotes/tn2002/tn2065.html>, in particular the bits at the beginning about "do shell script" not working exactly like Terminal.


--Chris Nebel AppleScript and Automator Engineering

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Shell script problem (From: "Manfred M. Strasser" <email@hidden>)
 >Re: Shell script problem (From: "Ronald 'Warui' Becher" <email@hidden>)
 >Re: Shell script problem (From: deivy petrescu <email@hidden>)

  • Prev by Date: Re: applescript for enabling root user...
  • Next by Date: find and replace question mark in Quark 6.5
  • Previous by thread: Re: Shell script problem
  • Next by thread: Stuck with GUI scripting
  • Index(es):
    • Date
    • Thread